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_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 zone_(zone), | 189 zone_(zone), |
190 classifier_(nullptr), | 190 classifier_(nullptr), |
191 scanner_(scanner), | 191 scanner_(scanner), |
192 stack_overflow_(false), | 192 stack_overflow_(false), |
193 default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile), | 193 default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile), |
194 allow_lazy_(false), | 194 allow_lazy_(false), |
195 allow_natives_(false), | 195 allow_natives_(false), |
196 allow_tailcalls_(false), | 196 allow_tailcalls_(false), |
197 allow_harmony_restrictive_declarations_(false), | 197 allow_harmony_restrictive_declarations_(false), |
198 allow_harmony_do_expressions_(false), | 198 allow_harmony_do_expressions_(false), |
199 allow_harmony_for_in_(false), | |
200 allow_harmony_function_sent_(false), | 199 allow_harmony_function_sent_(false), |
201 allow_harmony_async_await_(false), | 200 allow_harmony_async_await_(false), |
202 allow_harmony_restrictive_generators_(false), | 201 allow_harmony_restrictive_generators_(false), |
203 allow_harmony_trailing_commas_(false), | 202 allow_harmony_trailing_commas_(false), |
204 allow_harmony_class_fields_(false) {} | 203 allow_harmony_class_fields_(false) {} |
205 | 204 |
206 #define ALLOW_ACCESSORS(name) \ | 205 #define ALLOW_ACCESSORS(name) \ |
207 bool allow_##name() const { return allow_##name##_; } \ | 206 bool allow_##name() const { return allow_##name##_; } \ |
208 void set_allow_##name(bool allow) { allow_##name##_ = allow; } | 207 void set_allow_##name(bool allow) { allow_##name##_ = allow; } |
209 | 208 |
210 ALLOW_ACCESSORS(lazy); | 209 ALLOW_ACCESSORS(lazy); |
211 ALLOW_ACCESSORS(natives); | 210 ALLOW_ACCESSORS(natives); |
212 ALLOW_ACCESSORS(tailcalls); | 211 ALLOW_ACCESSORS(tailcalls); |
213 ALLOW_ACCESSORS(harmony_restrictive_declarations); | 212 ALLOW_ACCESSORS(harmony_restrictive_declarations); |
214 ALLOW_ACCESSORS(harmony_do_expressions); | 213 ALLOW_ACCESSORS(harmony_do_expressions); |
215 ALLOW_ACCESSORS(harmony_for_in); | |
216 ALLOW_ACCESSORS(harmony_function_sent); | 214 ALLOW_ACCESSORS(harmony_function_sent); |
217 ALLOW_ACCESSORS(harmony_async_await); | 215 ALLOW_ACCESSORS(harmony_async_await); |
218 ALLOW_ACCESSORS(harmony_restrictive_generators); | 216 ALLOW_ACCESSORS(harmony_restrictive_generators); |
219 ALLOW_ACCESSORS(harmony_trailing_commas); | 217 ALLOW_ACCESSORS(harmony_trailing_commas); |
220 ALLOW_ACCESSORS(harmony_class_fields); | 218 ALLOW_ACCESSORS(harmony_class_fields); |
221 | 219 |
222 #undef ALLOW_ACCESSORS | 220 #undef ALLOW_ACCESSORS |
223 | 221 |
224 uintptr_t stack_limit() const { return stack_limit_; } | 222 uintptr_t stack_limit() const { return stack_limit_; } |
225 | 223 |
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 Scanner* scanner_; | 1441 Scanner* scanner_; |
1444 bool stack_overflow_; | 1442 bool stack_overflow_; |
1445 | 1443 |
1446 FunctionLiteral::EagerCompileHint default_eager_compile_hint_; | 1444 FunctionLiteral::EagerCompileHint default_eager_compile_hint_; |
1447 | 1445 |
1448 bool allow_lazy_; | 1446 bool allow_lazy_; |
1449 bool allow_natives_; | 1447 bool allow_natives_; |
1450 bool allow_tailcalls_; | 1448 bool allow_tailcalls_; |
1451 bool allow_harmony_restrictive_declarations_; | 1449 bool allow_harmony_restrictive_declarations_; |
1452 bool allow_harmony_do_expressions_; | 1450 bool allow_harmony_do_expressions_; |
1453 bool allow_harmony_for_in_; | |
1454 bool allow_harmony_function_sent_; | 1451 bool allow_harmony_function_sent_; |
1455 bool allow_harmony_async_await_; | 1452 bool allow_harmony_async_await_; |
1456 bool allow_harmony_restrictive_generators_; | 1453 bool allow_harmony_restrictive_generators_; |
1457 bool allow_harmony_trailing_commas_; | 1454 bool allow_harmony_trailing_commas_; |
1458 bool allow_harmony_class_fields_; | 1455 bool allow_harmony_class_fields_; |
1459 | 1456 |
1460 friend class DiscardableZoneScope; | 1457 friend class DiscardableZoneScope; |
1461 }; | 1458 }; |
1462 | 1459 |
1463 template <typename Impl> | 1460 template <typename Impl> |
(...skipping 3710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5174 MessageTemplate::kForInOfLoopMultiBindings, | 5171 MessageTemplate::kForInOfLoopMultiBindings, |
5175 ForEachStatement::VisitModeString(for_info.mode)); | 5172 ForEachStatement::VisitModeString(for_info.mode)); |
5176 *ok = false; | 5173 *ok = false; |
5177 return impl()->NullStatement(); | 5174 return impl()->NullStatement(); |
5178 } | 5175 } |
5179 if (for_info.parsing_result.first_initializer_loc.IsValid() && | 5176 if (for_info.parsing_result.first_initializer_loc.IsValid() && |
5180 (is_strict(language_mode()) || | 5177 (is_strict(language_mode()) || |
5181 for_info.mode == ForEachStatement::ITERATE || | 5178 for_info.mode == ForEachStatement::ITERATE || |
5182 bound_names_are_lexical || | 5179 bound_names_are_lexical || |
5183 !impl()->IsIdentifier( | 5180 !impl()->IsIdentifier( |
5184 for_info.parsing_result.declarations[0].pattern) || | 5181 for_info.parsing_result.declarations[0].pattern))) { |
5185 allow_harmony_for_in())) { | |
5186 // Only increment the use count if we would have let this through | |
5187 // without the flag. | |
5188 if (allow_harmony_for_in()) { | |
5189 impl()->CountUsage(v8::Isolate::kForInInitializer); | |
5190 } | |
5191 impl()->ReportMessageAt( | 5182 impl()->ReportMessageAt( |
5192 for_info.parsing_result.first_initializer_loc, | 5183 for_info.parsing_result.first_initializer_loc, |
5193 MessageTemplate::kForInOfLoopInitializer, | 5184 MessageTemplate::kForInOfLoopInitializer, |
5194 ForEachStatement::VisitModeString(for_info.mode)); | 5185 ForEachStatement::VisitModeString(for_info.mode)); |
5195 *ok = false; | 5186 *ok = false; |
5196 return impl()->NullStatement(); | 5187 return impl()->NullStatement(); |
5197 } | 5188 } |
5198 | 5189 |
5199 BlockT init_block = impl()->RewriteForVarInLegacy(for_info); | 5190 BlockT init_block = impl()->RewriteForVarInLegacy(for_info); |
5200 | 5191 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5455 has_seen_constructor_ = true; | 5446 has_seen_constructor_ = true; |
5456 return; | 5447 return; |
5457 } | 5448 } |
5458 } | 5449 } |
5459 | 5450 |
5460 | 5451 |
5461 } // namespace internal | 5452 } // namespace internal |
5462 } // namespace v8 | 5453 } // namespace v8 |
5463 | 5454 |
5464 #endif // V8_PARSING_PARSER_BASE_H | 5455 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |