| 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/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
| 10 #include "src/hashmap.h" | 10 #include "src/hashmap.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 allow_natives_(false), | 109 allow_natives_(false), |
| 110 allow_harmony_sloppy_(false), | 110 allow_harmony_sloppy_(false), |
| 111 allow_harmony_sloppy_function_(false), | 111 allow_harmony_sloppy_function_(false), |
| 112 allow_harmony_sloppy_let_(false), | 112 allow_harmony_sloppy_let_(false), |
| 113 allow_harmony_default_parameters_(false), | 113 allow_harmony_default_parameters_(false), |
| 114 allow_harmony_destructuring_bind_(false), | 114 allow_harmony_destructuring_bind_(false), |
| 115 allow_harmony_destructuring_assignment_(false), | 115 allow_harmony_destructuring_assignment_(false), |
| 116 allow_strong_mode_(false), | 116 allow_strong_mode_(false), |
| 117 allow_legacy_const_(true), | 117 allow_legacy_const_(true), |
| 118 allow_harmony_do_expressions_(false), | 118 allow_harmony_do_expressions_(false), |
| 119 allow_harmony_function_name_(false) {} | 119 allow_harmony_function_name_(false), |
| 120 allow_harmony_function_sent_(false) {} |
| 120 | 121 |
| 121 #define ALLOW_ACCESSORS(name) \ | 122 #define ALLOW_ACCESSORS(name) \ |
| 122 bool allow_##name() const { return allow_##name##_; } \ | 123 bool allow_##name() const { return allow_##name##_; } \ |
| 123 void set_allow_##name(bool allow) { allow_##name##_ = allow; } | 124 void set_allow_##name(bool allow) { allow_##name##_ = allow; } |
| 124 | 125 |
| 125 ALLOW_ACCESSORS(lazy); | 126 ALLOW_ACCESSORS(lazy); |
| 126 ALLOW_ACCESSORS(natives); | 127 ALLOW_ACCESSORS(natives); |
| 127 ALLOW_ACCESSORS(harmony_sloppy); | 128 ALLOW_ACCESSORS(harmony_sloppy); |
| 128 ALLOW_ACCESSORS(harmony_sloppy_function); | 129 ALLOW_ACCESSORS(harmony_sloppy_function); |
| 129 ALLOW_ACCESSORS(harmony_sloppy_let); | 130 ALLOW_ACCESSORS(harmony_sloppy_let); |
| 130 ALLOW_ACCESSORS(harmony_default_parameters); | 131 ALLOW_ACCESSORS(harmony_default_parameters); |
| 131 ALLOW_ACCESSORS(harmony_destructuring_bind); | 132 ALLOW_ACCESSORS(harmony_destructuring_bind); |
| 132 ALLOW_ACCESSORS(harmony_destructuring_assignment); | 133 ALLOW_ACCESSORS(harmony_destructuring_assignment); |
| 133 ALLOW_ACCESSORS(strong_mode); | 134 ALLOW_ACCESSORS(strong_mode); |
| 134 ALLOW_ACCESSORS(legacy_const); | 135 ALLOW_ACCESSORS(legacy_const); |
| 135 ALLOW_ACCESSORS(harmony_do_expressions); | 136 ALLOW_ACCESSORS(harmony_do_expressions); |
| 136 ALLOW_ACCESSORS(harmony_function_name); | 137 ALLOW_ACCESSORS(harmony_function_name); |
| 138 ALLOW_ACCESSORS(harmony_function_sent); |
| 137 #undef ALLOW_ACCESSORS | 139 #undef ALLOW_ACCESSORS |
| 138 | 140 |
| 139 uintptr_t stack_limit() const { return stack_limit_; } | 141 uintptr_t stack_limit() const { return stack_limit_; } |
| 140 | 142 |
| 141 protected: | 143 protected: |
| 142 enum AllowRestrictedIdentifiers { | 144 enum AllowRestrictedIdentifiers { |
| 143 kAllowRestrictedIdentifiers, | 145 kAllowRestrictedIdentifiers, |
| 144 kDontAllowRestrictedIdentifiers | 146 kDontAllowRestrictedIdentifiers |
| 145 }; | 147 }; |
| 146 | 148 |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 bool allow_harmony_sloppy_; | 942 bool allow_harmony_sloppy_; |
| 941 bool allow_harmony_sloppy_function_; | 943 bool allow_harmony_sloppy_function_; |
| 942 bool allow_harmony_sloppy_let_; | 944 bool allow_harmony_sloppy_let_; |
| 943 bool allow_harmony_default_parameters_; | 945 bool allow_harmony_default_parameters_; |
| 944 bool allow_harmony_destructuring_bind_; | 946 bool allow_harmony_destructuring_bind_; |
| 945 bool allow_harmony_destructuring_assignment_; | 947 bool allow_harmony_destructuring_assignment_; |
| 946 bool allow_strong_mode_; | 948 bool allow_strong_mode_; |
| 947 bool allow_legacy_const_; | 949 bool allow_legacy_const_; |
| 948 bool allow_harmony_do_expressions_; | 950 bool allow_harmony_do_expressions_; |
| 949 bool allow_harmony_function_name_; | 951 bool allow_harmony_function_name_; |
| 952 bool allow_harmony_function_sent_; |
| 950 }; | 953 }; |
| 951 | 954 |
| 952 template <class Traits> | 955 template <class Traits> |
| 953 ParserBase<Traits>::FunctionState::FunctionState( | 956 ParserBase<Traits>::FunctionState::FunctionState( |
| 954 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope, | 957 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope, |
| 955 FunctionKind kind, typename Traits::Type::Factory* factory) | 958 FunctionKind kind, typename Traits::Type::Factory* factory) |
| 956 : next_materialized_literal_index_(0), | 959 : next_materialized_literal_index_(0), |
| 957 expected_property_count_(0), | 960 expected_property_count_(0), |
| 958 this_location_(Scanner::Location::invalid()), | 961 this_location_(Scanner::Location::invalid()), |
| 959 return_location_(Scanner::Location::invalid()), | 962 return_location_(Scanner::Location::invalid()), |
| (...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2536 | 2539 |
| 2537 // Parse the initial primary or function expression. | 2540 // Parse the initial primary or function expression. |
| 2538 ExpressionT result = this->EmptyExpression(); | 2541 ExpressionT result = this->EmptyExpression(); |
| 2539 if (peek() == Token::FUNCTION) { | 2542 if (peek() == Token::FUNCTION) { |
| 2540 BindingPatternUnexpectedToken(classifier); | 2543 BindingPatternUnexpectedToken(classifier); |
| 2541 ArrowFormalParametersUnexpectedToken(classifier); | 2544 ArrowFormalParametersUnexpectedToken(classifier); |
| 2542 | 2545 |
| 2543 Consume(Token::FUNCTION); | 2546 Consume(Token::FUNCTION); |
| 2544 int function_token_position = position(); | 2547 int function_token_position = position(); |
| 2545 | 2548 |
| 2546 if (FLAG_harmony_function_sent && peek() == Token::PERIOD) { | 2549 if (allow_harmony_function_sent() && peek() == Token::PERIOD) { |
| 2547 // function.sent | 2550 // function.sent |
| 2548 int pos = position(); | 2551 int pos = position(); |
| 2549 ExpectMetaProperty(CStrVector("sent"), "function.sent", pos, CHECK_OK); | 2552 ExpectMetaProperty(CStrVector("sent"), "function.sent", pos, CHECK_OK); |
| 2550 | 2553 |
| 2551 if (!is_generator()) { | 2554 if (!is_generator()) { |
| 2552 // TODO(neis): allow escaping into closures? | 2555 // TODO(neis): allow escaping into closures? |
| 2553 ReportMessageAt(scanner()->location(), | 2556 ReportMessageAt(scanner()->location(), |
| 2554 MessageTemplate::kUnexpectedFunctionSent); | 2557 MessageTemplate::kUnexpectedFunctionSent); |
| 2555 *ok = false; | 2558 *ok = false; |
| 2556 return this->EmptyExpression(); | 2559 return this->EmptyExpression(); |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3360 return; | 3363 return; |
| 3361 } | 3364 } |
| 3362 has_seen_constructor_ = true; | 3365 has_seen_constructor_ = true; |
| 3363 return; | 3366 return; |
| 3364 } | 3367 } |
| 3365 } | 3368 } |
| 3366 } // namespace internal | 3369 } // namespace internal |
| 3367 } // namespace v8 | 3370 } // namespace v8 |
| 3368 | 3371 |
| 3369 #endif // V8_PARSING_PARSER_BASE_H | 3372 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |