OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
7 | 7 |
8 #include "src/bailout-reason.h" | 8 #include "src/bailout-reason.h" |
9 #include "src/expression-classifier.h" | 9 #include "src/expression-classifier.h" |
10 #include "src/func-name-inferrer.h" | 10 #include "src/func-name-inferrer.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 fni_(NULL), | 100 fni_(NULL), |
101 ast_value_factory_(ast_value_factory), | 101 ast_value_factory_(ast_value_factory), |
102 log_(log), | 102 log_(log), |
103 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. | 103 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. |
104 stack_limit_(stack_limit), | 104 stack_limit_(stack_limit), |
105 zone_(zone), | 105 zone_(zone), |
106 scanner_(scanner), | 106 scanner_(scanner), |
107 stack_overflow_(false), | 107 stack_overflow_(false), |
108 allow_lazy_(false), | 108 allow_lazy_(false), |
109 allow_natives_(false), | 109 allow_natives_(false), |
110 allow_harmony_arrow_functions_(false), | |
111 allow_harmony_sloppy_(false), | 110 allow_harmony_sloppy_(false), |
112 allow_harmony_sloppy_function_(false), | 111 allow_harmony_sloppy_function_(false), |
113 allow_harmony_sloppy_let_(false), | 112 allow_harmony_sloppy_let_(false), |
114 allow_harmony_rest_parameters_(false), | 113 allow_harmony_rest_parameters_(false), |
115 allow_harmony_default_parameters_(false), | 114 allow_harmony_default_parameters_(false), |
116 allow_harmony_spread_calls_(false), | 115 allow_harmony_spread_calls_(false), |
117 allow_harmony_destructuring_(false), | 116 allow_harmony_destructuring_(false), |
118 allow_harmony_spread_arrays_(false), | 117 allow_harmony_spread_arrays_(false), |
119 allow_harmony_new_target_(false), | 118 allow_harmony_new_target_(false), |
120 allow_strong_mode_(false), | 119 allow_strong_mode_(false), |
121 allow_legacy_const_(true) {} | 120 allow_legacy_const_(true) {} |
122 | 121 |
123 #define ALLOW_ACCESSORS(name) \ | 122 #define ALLOW_ACCESSORS(name) \ |
124 bool allow_##name() const { return allow_##name##_; } \ | 123 bool allow_##name() const { return allow_##name##_; } \ |
125 void set_allow_##name(bool allow) { allow_##name##_ = allow; } | 124 void set_allow_##name(bool allow) { allow_##name##_ = allow; } |
126 | 125 |
127 ALLOW_ACCESSORS(lazy); | 126 ALLOW_ACCESSORS(lazy); |
128 ALLOW_ACCESSORS(natives); | 127 ALLOW_ACCESSORS(natives); |
129 ALLOW_ACCESSORS(harmony_arrow_functions); | |
130 ALLOW_ACCESSORS(harmony_sloppy); | 128 ALLOW_ACCESSORS(harmony_sloppy); |
131 ALLOW_ACCESSORS(harmony_sloppy_function); | 129 ALLOW_ACCESSORS(harmony_sloppy_function); |
132 ALLOW_ACCESSORS(harmony_sloppy_let); | 130 ALLOW_ACCESSORS(harmony_sloppy_let); |
133 ALLOW_ACCESSORS(harmony_rest_parameters); | 131 ALLOW_ACCESSORS(harmony_rest_parameters); |
134 ALLOW_ACCESSORS(harmony_default_parameters); | 132 ALLOW_ACCESSORS(harmony_default_parameters); |
135 ALLOW_ACCESSORS(harmony_spread_calls); | 133 ALLOW_ACCESSORS(harmony_spread_calls); |
136 ALLOW_ACCESSORS(harmony_destructuring); | 134 ALLOW_ACCESSORS(harmony_destructuring); |
137 ALLOW_ACCESSORS(harmony_spread_arrays); | 135 ALLOW_ACCESSORS(harmony_spread_arrays); |
138 ALLOW_ACCESSORS(harmony_new_target); | 136 ALLOW_ACCESSORS(harmony_new_target); |
139 ALLOW_ACCESSORS(strong_mode); | 137 ALLOW_ACCESSORS(strong_mode); |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 uintptr_t stack_limit_; | 818 uintptr_t stack_limit_; |
821 | 819 |
822 private: | 820 private: |
823 Zone* zone_; | 821 Zone* zone_; |
824 | 822 |
825 Scanner* scanner_; | 823 Scanner* scanner_; |
826 bool stack_overflow_; | 824 bool stack_overflow_; |
827 | 825 |
828 bool allow_lazy_; | 826 bool allow_lazy_; |
829 bool allow_natives_; | 827 bool allow_natives_; |
830 bool allow_harmony_arrow_functions_; | |
831 bool allow_harmony_sloppy_; | 828 bool allow_harmony_sloppy_; |
832 bool allow_harmony_sloppy_function_; | 829 bool allow_harmony_sloppy_function_; |
833 bool allow_harmony_sloppy_let_; | 830 bool allow_harmony_sloppy_let_; |
834 bool allow_harmony_rest_parameters_; | 831 bool allow_harmony_rest_parameters_; |
835 bool allow_harmony_default_parameters_; | 832 bool allow_harmony_default_parameters_; |
836 bool allow_harmony_spread_calls_; | 833 bool allow_harmony_spread_calls_; |
837 bool allow_harmony_destructuring_; | 834 bool allow_harmony_destructuring_; |
838 bool allow_harmony_spread_arrays_; | 835 bool allow_harmony_spread_arrays_; |
839 bool allow_harmony_new_target_; | 836 bool allow_harmony_new_target_; |
840 bool allow_strong_mode_; | 837 bool allow_strong_mode_; |
(...skipping 2067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2908 | 2905 |
2909 if (fni_ != NULL) fni_->Enter(); | 2906 if (fni_ != NULL) fni_->Enter(); |
2910 ParserBase<Traits>::Checkpoint checkpoint(this); | 2907 ParserBase<Traits>::Checkpoint checkpoint(this); |
2911 ExpressionClassifier arrow_formals_classifier(classifier->duplicate_finder()); | 2908 ExpressionClassifier arrow_formals_classifier(classifier->duplicate_finder()); |
2912 bool parenthesized_formals = peek() == Token::LPAREN; | 2909 bool parenthesized_formals = peek() == Token::LPAREN; |
2913 if (!parenthesized_formals) { | 2910 if (!parenthesized_formals) { |
2914 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier); | 2911 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier); |
2915 } | 2912 } |
2916 ExpressionT expression = this->ParseConditionalExpression( | 2913 ExpressionT expression = this->ParseConditionalExpression( |
2917 accept_IN, &arrow_formals_classifier, CHECK_OK); | 2914 accept_IN, &arrow_formals_classifier, CHECK_OK); |
2918 if (allow_harmony_arrow_functions() && peek() == Token::ARROW) { | 2915 if (peek() == Token::ARROW) { |
2919 BindingPatternUnexpectedToken(classifier); | 2916 BindingPatternUnexpectedToken(classifier); |
2920 ValidateArrowFormalParameters(&arrow_formals_classifier, expression, | 2917 ValidateArrowFormalParameters(&arrow_formals_classifier, expression, |
2921 parenthesized_formals, CHECK_OK); | 2918 parenthesized_formals, CHECK_OK); |
2922 Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); | 2919 Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); |
2923 Scope* scope = | 2920 Scope* scope = |
2924 this->NewScope(scope_, ARROW_SCOPE, FunctionKind::kArrowFunction); | 2921 this->NewScope(scope_, ARROW_SCOPE, FunctionKind::kArrowFunction); |
2925 FormalParametersT parameters(scope); | 2922 FormalParametersT parameters(scope); |
2926 if (!arrow_formals_classifier.is_simple_parameter_list()) { | 2923 if (!arrow_formals_classifier.is_simple_parameter_list()) { |
2927 scope->SetHasNonSimpleParameters(); | 2924 scope->SetHasNonSimpleParameters(); |
2928 parameters.is_simple = false; | 2925 parameters.is_simple = false; |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4180 return; | 4177 return; |
4181 } | 4178 } |
4182 has_seen_constructor_ = true; | 4179 has_seen_constructor_ = true; |
4183 return; | 4180 return; |
4184 } | 4181 } |
4185 } | 4182 } |
4186 } // namespace internal | 4183 } // namespace internal |
4187 } // namespace v8 | 4184 } // namespace v8 |
4188 | 4185 |
4189 #endif // V8_PREPARSER_H | 4186 #endif // V8_PREPARSER_H |
OLD | NEW |