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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 scanner_(scanner), | 107 scanner_(scanner), |
108 stack_overflow_(false), | 108 stack_overflow_(false), |
109 allow_lazy_(false), | 109 allow_lazy_(false), |
110 allow_natives_(false), | 110 allow_natives_(false), |
111 allow_harmony_sloppy_(false), | 111 allow_harmony_sloppy_(false), |
112 allow_harmony_sloppy_function_(false), | 112 allow_harmony_sloppy_function_(false), |
113 allow_harmony_sloppy_let_(false), | 113 allow_harmony_sloppy_let_(false), |
114 allow_harmony_rest_parameters_(false), | 114 allow_harmony_rest_parameters_(false), |
115 allow_harmony_default_parameters_(false), | 115 allow_harmony_default_parameters_(false), |
116 allow_harmony_destructuring_(false), | 116 allow_harmony_destructuring_(false), |
117 allow_harmony_new_target_(false), | |
118 allow_strong_mode_(false), | 117 allow_strong_mode_(false), |
119 allow_legacy_const_(true), | 118 allow_legacy_const_(true), |
120 allow_harmony_do_expressions_(false) {} | 119 allow_harmony_do_expressions_(false) {} |
121 | 120 |
122 #define ALLOW_ACCESSORS(name) \ | 121 #define ALLOW_ACCESSORS(name) \ |
123 bool allow_##name() const { return allow_##name##_; } \ | 122 bool allow_##name() const { return allow_##name##_; } \ |
124 void set_allow_##name(bool allow) { allow_##name##_ = allow; } | 123 void set_allow_##name(bool allow) { allow_##name##_ = allow; } |
125 | 124 |
126 ALLOW_ACCESSORS(lazy); | 125 ALLOW_ACCESSORS(lazy); |
127 ALLOW_ACCESSORS(natives); | 126 ALLOW_ACCESSORS(natives); |
128 ALLOW_ACCESSORS(harmony_sloppy); | 127 ALLOW_ACCESSORS(harmony_sloppy); |
129 ALLOW_ACCESSORS(harmony_sloppy_function); | 128 ALLOW_ACCESSORS(harmony_sloppy_function); |
130 ALLOW_ACCESSORS(harmony_sloppy_let); | 129 ALLOW_ACCESSORS(harmony_sloppy_let); |
131 ALLOW_ACCESSORS(harmony_rest_parameters); | 130 ALLOW_ACCESSORS(harmony_rest_parameters); |
132 ALLOW_ACCESSORS(harmony_default_parameters); | 131 ALLOW_ACCESSORS(harmony_default_parameters); |
133 ALLOW_ACCESSORS(harmony_destructuring); | 132 ALLOW_ACCESSORS(harmony_destructuring); |
134 ALLOW_ACCESSORS(harmony_new_target); | |
135 ALLOW_ACCESSORS(strong_mode); | 133 ALLOW_ACCESSORS(strong_mode); |
136 ALLOW_ACCESSORS(legacy_const); | 134 ALLOW_ACCESSORS(legacy_const); |
137 ALLOW_ACCESSORS(harmony_do_expressions); | 135 ALLOW_ACCESSORS(harmony_do_expressions); |
138 #undef ALLOW_ACCESSORS | 136 #undef ALLOW_ACCESSORS |
139 | 137 |
140 uintptr_t stack_limit() const { return stack_limit_; } | 138 uintptr_t stack_limit() const { return stack_limit_; } |
141 | 139 |
142 protected: | 140 protected: |
143 enum AllowRestrictedIdentifiers { | 141 enum AllowRestrictedIdentifiers { |
144 kAllowRestrictedIdentifiers, | 142 kAllowRestrictedIdentifiers, |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 bool stack_overflow_; | 829 bool stack_overflow_; |
832 | 830 |
833 bool allow_lazy_; | 831 bool allow_lazy_; |
834 bool allow_natives_; | 832 bool allow_natives_; |
835 bool allow_harmony_sloppy_; | 833 bool allow_harmony_sloppy_; |
836 bool allow_harmony_sloppy_function_; | 834 bool allow_harmony_sloppy_function_; |
837 bool allow_harmony_sloppy_let_; | 835 bool allow_harmony_sloppy_let_; |
838 bool allow_harmony_rest_parameters_; | 836 bool allow_harmony_rest_parameters_; |
839 bool allow_harmony_default_parameters_; | 837 bool allow_harmony_default_parameters_; |
840 bool allow_harmony_destructuring_; | 838 bool allow_harmony_destructuring_; |
841 bool allow_harmony_new_target_; | |
842 bool allow_strong_mode_; | 839 bool allow_strong_mode_; |
843 bool allow_legacy_const_; | 840 bool allow_legacy_const_; |
844 bool allow_harmony_do_expressions_; | 841 bool allow_harmony_do_expressions_; |
845 }; | 842 }; |
846 | 843 |
847 | 844 |
848 class PreParserIdentifier { | 845 class PreParserIdentifier { |
849 public: | 846 public: |
850 PreParserIdentifier() : type_(kUnknownIdentifier) {} | 847 PreParserIdentifier() : type_(kUnknownIdentifier) {} |
851 static PreParserIdentifier Default() { | 848 static PreParserIdentifier Default() { |
(...skipping 2542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3394 | 3391 |
3395 if (peek() == Token::NEW) { | 3392 if (peek() == Token::NEW) { |
3396 BindingPatternUnexpectedToken(classifier); | 3393 BindingPatternUnexpectedToken(classifier); |
3397 ArrowFormalParametersUnexpectedToken(classifier); | 3394 ArrowFormalParametersUnexpectedToken(classifier); |
3398 Consume(Token::NEW); | 3395 Consume(Token::NEW); |
3399 int new_pos = position(); | 3396 int new_pos = position(); |
3400 ExpressionT result = this->EmptyExpression(); | 3397 ExpressionT result = this->EmptyExpression(); |
3401 if (peek() == Token::SUPER) { | 3398 if (peek() == Token::SUPER) { |
3402 const bool is_new = true; | 3399 const bool is_new = true; |
3403 result = ParseSuperExpression(is_new, classifier, CHECK_OK); | 3400 result = ParseSuperExpression(is_new, classifier, CHECK_OK); |
3404 } else if (allow_harmony_new_target() && peek() == Token::PERIOD) { | 3401 } else if (peek() == Token::PERIOD) { |
3405 return ParseNewTargetExpression(CHECK_OK); | 3402 return ParseNewTargetExpression(CHECK_OK); |
3406 } else { | 3403 } else { |
3407 result = this->ParseMemberWithNewPrefixesExpression(classifier, CHECK_OK); | 3404 result = this->ParseMemberWithNewPrefixesExpression(classifier, CHECK_OK); |
3408 } | 3405 } |
3409 if (peek() == Token::LPAREN) { | 3406 if (peek() == Token::LPAREN) { |
3410 // NewExpression with arguments. | 3407 // NewExpression with arguments. |
3411 Scanner::Location spread_pos; | 3408 Scanner::Location spread_pos; |
3412 typename Traits::Type::ExpressionList args = | 3409 typename Traits::Type::ExpressionList args = |
3413 this->ParseArguments(&spread_pos, classifier, CHECK_OK); | 3410 this->ParseArguments(&spread_pos, classifier, CHECK_OK); |
3414 | 3411 |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4203 return; | 4200 return; |
4204 } | 4201 } |
4205 has_seen_constructor_ = true; | 4202 has_seen_constructor_ = true; |
4206 return; | 4203 return; |
4207 } | 4204 } |
4208 } | 4205 } |
4209 } // namespace internal | 4206 } // namespace internal |
4210 } // namespace v8 | 4207 } // namespace v8 |
4211 | 4208 |
4212 #endif // V8_PREPARSER_H | 4209 #endif // V8_PREPARSER_H |
OLD | NEW |