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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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), | 110 allow_harmony_arrow_functions_(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_spreadcalls_(false), | 116 allow_harmony_spread_calls_(false), |
117 allow_harmony_destructuring_(false), | 117 allow_harmony_destructuring_(false), |
118 allow_harmony_spread_arrays_(false), | 118 allow_harmony_spread_arrays_(false), |
119 allow_harmony_new_target_(false), | 119 allow_harmony_new_target_(false), |
120 allow_strong_mode_(false), | 120 allow_strong_mode_(false), |
121 allow_legacy_const_(true) {} | 121 allow_legacy_const_(true) {} |
122 | 122 |
123 #define ALLOW_ACCESSORS(name) \ | 123 #define ALLOW_ACCESSORS(name) \ |
124 bool allow_##name() const { return allow_##name##_; } \ | 124 bool allow_##name() const { return allow_##name##_; } \ |
125 void set_allow_##name(bool allow) { allow_##name##_ = allow; } | 125 void set_allow_##name(bool allow) { allow_##name##_ = allow; } |
126 | 126 |
127 ALLOW_ACCESSORS(lazy); | 127 ALLOW_ACCESSORS(lazy); |
128 ALLOW_ACCESSORS(natives); | 128 ALLOW_ACCESSORS(natives); |
129 ALLOW_ACCESSORS(harmony_arrow_functions); | 129 ALLOW_ACCESSORS(harmony_arrow_functions); |
130 ALLOW_ACCESSORS(harmony_sloppy); | 130 ALLOW_ACCESSORS(harmony_sloppy); |
131 ALLOW_ACCESSORS(harmony_sloppy_function); | 131 ALLOW_ACCESSORS(harmony_sloppy_function); |
132 ALLOW_ACCESSORS(harmony_sloppy_let); | 132 ALLOW_ACCESSORS(harmony_sloppy_let); |
133 ALLOW_ACCESSORS(harmony_rest_parameters); | 133 ALLOW_ACCESSORS(harmony_rest_parameters); |
134 ALLOW_ACCESSORS(harmony_default_parameters); | 134 ALLOW_ACCESSORS(harmony_default_parameters); |
135 ALLOW_ACCESSORS(harmony_spreadcalls); | 135 ALLOW_ACCESSORS(harmony_spread_calls); |
136 ALLOW_ACCESSORS(harmony_destructuring); | 136 ALLOW_ACCESSORS(harmony_destructuring); |
137 ALLOW_ACCESSORS(harmony_spread_arrays); | 137 ALLOW_ACCESSORS(harmony_spread_arrays); |
138 ALLOW_ACCESSORS(harmony_new_target); | 138 ALLOW_ACCESSORS(harmony_new_target); |
139 ALLOW_ACCESSORS(strong_mode); | 139 ALLOW_ACCESSORS(strong_mode); |
140 ALLOW_ACCESSORS(legacy_const); | 140 ALLOW_ACCESSORS(legacy_const); |
141 #undef ALLOW_ACCESSORS | 141 #undef ALLOW_ACCESSORS |
142 | 142 |
143 protected: | 143 protected: |
144 enum AllowRestrictedIdentifiers { | 144 enum AllowRestrictedIdentifiers { |
145 kAllowRestrictedIdentifiers, | 145 kAllowRestrictedIdentifiers, |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 bool stack_overflow_; | 826 bool stack_overflow_; |
827 | 827 |
828 bool allow_lazy_; | 828 bool allow_lazy_; |
829 bool allow_natives_; | 829 bool allow_natives_; |
830 bool allow_harmony_arrow_functions_; | 830 bool allow_harmony_arrow_functions_; |
831 bool allow_harmony_sloppy_; | 831 bool allow_harmony_sloppy_; |
832 bool allow_harmony_sloppy_function_; | 832 bool allow_harmony_sloppy_function_; |
833 bool allow_harmony_sloppy_let_; | 833 bool allow_harmony_sloppy_let_; |
834 bool allow_harmony_rest_parameters_; | 834 bool allow_harmony_rest_parameters_; |
835 bool allow_harmony_default_parameters_; | 835 bool allow_harmony_default_parameters_; |
836 bool allow_harmony_spreadcalls_; | 836 bool allow_harmony_spread_calls_; |
837 bool allow_harmony_destructuring_; | 837 bool allow_harmony_destructuring_; |
838 bool allow_harmony_spread_arrays_; | 838 bool allow_harmony_spread_arrays_; |
839 bool allow_harmony_new_target_; | 839 bool allow_harmony_new_target_; |
840 bool allow_strong_mode_; | 840 bool allow_strong_mode_; |
841 bool allow_legacy_const_; | 841 bool allow_legacy_const_; |
842 }; | 842 }; |
843 | 843 |
844 | 844 |
845 class PreParserIdentifier { | 845 class PreParserIdentifier { |
846 public: | 846 public: |
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2828 // '(' (AssignmentExpression)*[','] ')' | 2828 // '(' (AssignmentExpression)*[','] ')' |
2829 | 2829 |
2830 Scanner::Location spread_arg = Scanner::Location::invalid(); | 2830 Scanner::Location spread_arg = Scanner::Location::invalid(); |
2831 typename Traits::Type::ExpressionList result = | 2831 typename Traits::Type::ExpressionList result = |
2832 this->NewExpressionList(4, zone_); | 2832 this->NewExpressionList(4, zone_); |
2833 Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList)); | 2833 Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList)); |
2834 bool done = (peek() == Token::RPAREN); | 2834 bool done = (peek() == Token::RPAREN); |
2835 bool was_unspread = false; | 2835 bool was_unspread = false; |
2836 int unspread_sequences_count = 0; | 2836 int unspread_sequences_count = 0; |
2837 while (!done) { | 2837 while (!done) { |
2838 bool is_spread = allow_harmony_spreadcalls() && (peek() == Token::ELLIPSIS); | 2838 bool is_spread = |
| 2839 allow_harmony_spread_calls() && (peek() == Token::ELLIPSIS); |
2839 int start_pos = peek_position(); | 2840 int start_pos = peek_position(); |
2840 if (is_spread) Consume(Token::ELLIPSIS); | 2841 if (is_spread) Consume(Token::ELLIPSIS); |
2841 | 2842 |
2842 ExpressionT argument = this->ParseAssignmentExpression( | 2843 ExpressionT argument = this->ParseAssignmentExpression( |
2843 true, classifier, CHECK_OK_CUSTOM(NullExpressionList)); | 2844 true, classifier, CHECK_OK_CUSTOM(NullExpressionList)); |
2844 if (is_spread) { | 2845 if (is_spread) { |
2845 if (!spread_arg.IsValid()) { | 2846 if (!spread_arg.IsValid()) { |
2846 spread_arg.beg_pos = start_pos; | 2847 spread_arg.beg_pos = start_pos; |
2847 spread_arg.end_pos = peek_position(); | 2848 spread_arg.end_pos = peek_position(); |
2848 } | 2849 } |
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4178 *ok = false; | 4179 *ok = false; |
4179 return; | 4180 return; |
4180 } | 4181 } |
4181 has_seen_constructor_ = true; | 4182 has_seen_constructor_ = true; |
4182 return; | 4183 return; |
4183 } | 4184 } |
4184 } | 4185 } |
4185 } } // v8::internal | 4186 } } // v8::internal |
4186 | 4187 |
4187 #endif // V8_PREPARSER_H | 4188 #endif // V8_PREPARSER_H |
OLD | NEW |