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/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. | 104 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. |
105 stack_limit_(stack_limit), | 105 stack_limit_(stack_limit), |
106 zone_(zone), | 106 zone_(zone), |
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_arrow_functions_(false), | 111 allow_harmony_arrow_functions_(false), |
112 allow_harmony_sloppy_(false), | 112 allow_harmony_sloppy_(false), |
113 allow_harmony_sloppy_let_(false), | 113 allow_harmony_sloppy_let_(false), |
114 allow_harmony_computed_property_names_(false), | |
115 allow_harmony_rest_parameters_(false), | 114 allow_harmony_rest_parameters_(false), |
116 allow_harmony_spreadcalls_(false), | 115 allow_harmony_spreadcalls_(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); | 128 ALLOW_ACCESSORS(harmony_arrow_functions); |
130 ALLOW_ACCESSORS(harmony_sloppy); | 129 ALLOW_ACCESSORS(harmony_sloppy); |
131 ALLOW_ACCESSORS(harmony_sloppy_let); | 130 ALLOW_ACCESSORS(harmony_sloppy_let); |
132 ALLOW_ACCESSORS(harmony_computed_property_names); | |
133 ALLOW_ACCESSORS(harmony_rest_parameters); | 131 ALLOW_ACCESSORS(harmony_rest_parameters); |
134 ALLOW_ACCESSORS(harmony_spreadcalls); | 132 ALLOW_ACCESSORS(harmony_spreadcalls); |
135 ALLOW_ACCESSORS(harmony_destructuring); | 133 ALLOW_ACCESSORS(harmony_destructuring); |
136 ALLOW_ACCESSORS(harmony_spread_arrays); | 134 ALLOW_ACCESSORS(harmony_spread_arrays); |
137 ALLOW_ACCESSORS(harmony_new_target); | 135 ALLOW_ACCESSORS(harmony_new_target); |
138 ALLOW_ACCESSORS(strong_mode); | 136 ALLOW_ACCESSORS(strong_mode); |
139 ALLOW_ACCESSORS(legacy_const); | 137 ALLOW_ACCESSORS(legacy_const); |
140 #undef ALLOW_ACCESSORS | 138 #undef ALLOW_ACCESSORS |
141 | 139 |
142 protected: | 140 protected: |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 Zone* zone_; | 794 Zone* zone_; |
797 | 795 |
798 Scanner* scanner_; | 796 Scanner* scanner_; |
799 bool stack_overflow_; | 797 bool stack_overflow_; |
800 | 798 |
801 bool allow_lazy_; | 799 bool allow_lazy_; |
802 bool allow_natives_; | 800 bool allow_natives_; |
803 bool allow_harmony_arrow_functions_; | 801 bool allow_harmony_arrow_functions_; |
804 bool allow_harmony_sloppy_; | 802 bool allow_harmony_sloppy_; |
805 bool allow_harmony_sloppy_let_; | 803 bool allow_harmony_sloppy_let_; |
806 bool allow_harmony_computed_property_names_; | |
807 bool allow_harmony_rest_parameters_; | 804 bool allow_harmony_rest_parameters_; |
808 bool allow_harmony_spreadcalls_; | 805 bool allow_harmony_spreadcalls_; |
809 bool allow_harmony_destructuring_; | 806 bool allow_harmony_destructuring_; |
810 bool allow_harmony_spread_arrays_; | 807 bool allow_harmony_spread_arrays_; |
811 bool allow_harmony_new_target_; | 808 bool allow_harmony_new_target_; |
812 bool allow_strong_mode_; | 809 bool allow_strong_mode_; |
813 bool allow_legacy_const_; | 810 bool allow_legacy_const_; |
814 }; | 811 }; |
815 | 812 |
816 | 813 |
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2496 case Token::SMI: | 2493 case Token::SMI: |
2497 Consume(Token::SMI); | 2494 Consume(Token::SMI); |
2498 *name = this->GetNumberAsSymbol(scanner()); | 2495 *name = this->GetNumberAsSymbol(scanner()); |
2499 break; | 2496 break; |
2500 | 2497 |
2501 case Token::NUMBER: | 2498 case Token::NUMBER: |
2502 Consume(Token::NUMBER); | 2499 Consume(Token::NUMBER); |
2503 *name = this->GetNumberAsSymbol(scanner()); | 2500 *name = this->GetNumberAsSymbol(scanner()); |
2504 break; | 2501 break; |
2505 | 2502 |
2506 case Token::LBRACK: | 2503 case Token::LBRACK: { |
2507 if (allow_harmony_computed_property_names_) { | 2504 *is_computed_name = true; |
2508 *is_computed_name = true; | 2505 Consume(Token::LBRACK); |
2509 Consume(Token::LBRACK); | 2506 ExpressionClassifier computed_name_classifier; |
2510 ExpressionClassifier computed_name_classifier; | 2507 ExpressionT expression = |
2511 ExpressionT expression = ParseAssignmentExpression( | 2508 ParseAssignmentExpression(true, &computed_name_classifier, CHECK_OK); |
2512 true, &computed_name_classifier, CHECK_OK); | 2509 classifier->AccumulateReclassifyingAsPattern(computed_name_classifier); |
2513 classifier->AccumulateReclassifyingAsPattern(computed_name_classifier); | 2510 Expect(Token::RBRACK, CHECK_OK); |
2514 Expect(Token::RBRACK, CHECK_OK); | 2511 return expression; |
2515 return expression; | 2512 } |
2516 } | |
2517 | 2513 |
2518 // Fall through. | |
2519 case Token::STATIC: | 2514 case Token::STATIC: |
2520 *is_static = true; | 2515 *is_static = true; |
2521 | 2516 |
2522 // Fall through. | 2517 // Fall through. |
2523 default: | 2518 default: |
2524 *name = ParseIdentifierNameOrGetOrSet(is_get, is_set, CHECK_OK); | 2519 *name = ParseIdentifierNameOrGetOrSet(is_get, is_set, CHECK_OK); |
2525 break; | 2520 break; |
2526 } | 2521 } |
2527 | 2522 |
2528 uint32_t index; | 2523 uint32_t index; |
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4024 *ok = false; | 4019 *ok = false; |
4025 return; | 4020 return; |
4026 } | 4021 } |
4027 has_seen_constructor_ = true; | 4022 has_seen_constructor_ = true; |
4028 return; | 4023 return; |
4029 } | 4024 } |
4030 } | 4025 } |
4031 } } // v8::internal | 4026 } } // v8::internal |
4032 | 4027 |
4033 #endif // V8_PREPARSER_H | 4028 #endif // V8_PREPARSER_H |
OLD | NEW |