| 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 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_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_spread_calls_(false), | |
| 117 allow_harmony_destructuring_(false), | 116 allow_harmony_destructuring_(false), |
| 118 allow_harmony_spread_arrays_(false), | |
| 119 allow_harmony_new_target_(false), | 117 allow_harmony_new_target_(false), |
| 120 allow_strong_mode_(false), | 118 allow_strong_mode_(false), |
| 121 allow_legacy_const_(true), | 119 allow_legacy_const_(true), |
| 122 allow_harmony_do_expressions_(false) {} | 120 allow_harmony_do_expressions_(false) {} |
| 123 | 121 |
| 124 #define ALLOW_ACCESSORS(name) \ | 122 #define ALLOW_ACCESSORS(name) \ |
| 125 bool allow_##name() const { return allow_##name##_; } \ | 123 bool allow_##name() const { return allow_##name##_; } \ |
| 126 void set_allow_##name(bool allow) { allow_##name##_ = allow; } | 124 void set_allow_##name(bool allow) { allow_##name##_ = allow; } |
| 127 | 125 |
| 128 ALLOW_ACCESSORS(lazy); | 126 ALLOW_ACCESSORS(lazy); |
| 129 ALLOW_ACCESSORS(natives); | 127 ALLOW_ACCESSORS(natives); |
| 130 ALLOW_ACCESSORS(harmony_sloppy); | 128 ALLOW_ACCESSORS(harmony_sloppy); |
| 131 ALLOW_ACCESSORS(harmony_sloppy_function); | 129 ALLOW_ACCESSORS(harmony_sloppy_function); |
| 132 ALLOW_ACCESSORS(harmony_sloppy_let); | 130 ALLOW_ACCESSORS(harmony_sloppy_let); |
| 133 ALLOW_ACCESSORS(harmony_rest_parameters); | 131 ALLOW_ACCESSORS(harmony_rest_parameters); |
| 134 ALLOW_ACCESSORS(harmony_default_parameters); | 132 ALLOW_ACCESSORS(harmony_default_parameters); |
| 135 ALLOW_ACCESSORS(harmony_spread_calls); | |
| 136 ALLOW_ACCESSORS(harmony_destructuring); | 133 ALLOW_ACCESSORS(harmony_destructuring); |
| 137 ALLOW_ACCESSORS(harmony_spread_arrays); | |
| 138 ALLOW_ACCESSORS(harmony_new_target); | 134 ALLOW_ACCESSORS(harmony_new_target); |
| 139 ALLOW_ACCESSORS(strong_mode); | 135 ALLOW_ACCESSORS(strong_mode); |
| 140 ALLOW_ACCESSORS(legacy_const); | 136 ALLOW_ACCESSORS(legacy_const); |
| 141 ALLOW_ACCESSORS(harmony_do_expressions); | 137 ALLOW_ACCESSORS(harmony_do_expressions); |
| 142 #undef ALLOW_ACCESSORS | 138 #undef ALLOW_ACCESSORS |
| 143 | 139 |
| 144 uintptr_t stack_limit() const { return stack_limit_; } | 140 uintptr_t stack_limit() const { return stack_limit_; } |
| 145 | 141 |
| 146 protected: | 142 protected: |
| 147 enum AllowRestrictedIdentifiers { | 143 enum AllowRestrictedIdentifiers { |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 Scanner* scanner_; | 830 Scanner* scanner_; |
| 835 bool stack_overflow_; | 831 bool stack_overflow_; |
| 836 | 832 |
| 837 bool allow_lazy_; | 833 bool allow_lazy_; |
| 838 bool allow_natives_; | 834 bool allow_natives_; |
| 839 bool allow_harmony_sloppy_; | 835 bool allow_harmony_sloppy_; |
| 840 bool allow_harmony_sloppy_function_; | 836 bool allow_harmony_sloppy_function_; |
| 841 bool allow_harmony_sloppy_let_; | 837 bool allow_harmony_sloppy_let_; |
| 842 bool allow_harmony_rest_parameters_; | 838 bool allow_harmony_rest_parameters_; |
| 843 bool allow_harmony_default_parameters_; | 839 bool allow_harmony_default_parameters_; |
| 844 bool allow_harmony_spread_calls_; | |
| 845 bool allow_harmony_destructuring_; | 840 bool allow_harmony_destructuring_; |
| 846 bool allow_harmony_spread_arrays_; | |
| 847 bool allow_harmony_new_target_; | 841 bool allow_harmony_new_target_; |
| 848 bool allow_strong_mode_; | 842 bool allow_strong_mode_; |
| 849 bool allow_legacy_const_; | 843 bool allow_legacy_const_; |
| 850 bool allow_harmony_do_expressions_; | 844 bool allow_harmony_do_expressions_; |
| 851 }; | 845 }; |
| 852 | 846 |
| 853 | 847 |
| 854 class PreParserIdentifier { | 848 class PreParserIdentifier { |
| 855 public: | 849 public: |
| 856 PreParserIdentifier() : type_(kUnknownIdentifier) {} | 850 PreParserIdentifier() : type_(kUnknownIdentifier) {} |
| (...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2516 ExpressionT elem = this->EmptyExpression(); | 2510 ExpressionT elem = this->EmptyExpression(); |
| 2517 if (peek() == Token::COMMA) { | 2511 if (peek() == Token::COMMA) { |
| 2518 if (is_strong(language_mode())) { | 2512 if (is_strong(language_mode())) { |
| 2519 ReportMessageAt(scanner()->peek_location(), | 2513 ReportMessageAt(scanner()->peek_location(), |
| 2520 MessageTemplate::kStrongEllision); | 2514 MessageTemplate::kStrongEllision); |
| 2521 *ok = false; | 2515 *ok = false; |
| 2522 return this->EmptyExpression(); | 2516 return this->EmptyExpression(); |
| 2523 } | 2517 } |
| 2524 elem = this->GetLiteralTheHole(peek_position(), factory()); | 2518 elem = this->GetLiteralTheHole(peek_position(), factory()); |
| 2525 } else if (peek() == Token::ELLIPSIS) { | 2519 } else if (peek() == Token::ELLIPSIS) { |
| 2526 if (!allow_harmony_spread_arrays()) { | |
| 2527 ExpressionUnexpectedToken(classifier); | |
| 2528 } | |
| 2529 int start_pos = peek_position(); | 2520 int start_pos = peek_position(); |
| 2530 Consume(Token::ELLIPSIS); | 2521 Consume(Token::ELLIPSIS); |
| 2531 ExpressionT argument = | 2522 ExpressionT argument = |
| 2532 this->ParseAssignmentExpression(true, classifier, CHECK_OK); | 2523 this->ParseAssignmentExpression(true, classifier, CHECK_OK); |
| 2533 elem = factory()->NewSpread(argument, start_pos); | 2524 elem = factory()->NewSpread(argument, start_pos); |
| 2534 seen_spread = true; | 2525 seen_spread = true; |
| 2535 if (first_spread_index < 0) { | 2526 if (first_spread_index < 0) { |
| 2536 first_spread_index = values->length(); | 2527 first_spread_index = values->length(); |
| 2537 } | 2528 } |
| 2538 } else { | 2529 } else { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2862 // '(' (AssignmentExpression)*[','] ')' | 2853 // '(' (AssignmentExpression)*[','] ')' |
| 2863 | 2854 |
| 2864 Scanner::Location spread_arg = Scanner::Location::invalid(); | 2855 Scanner::Location spread_arg = Scanner::Location::invalid(); |
| 2865 typename Traits::Type::ExpressionList result = | 2856 typename Traits::Type::ExpressionList result = |
| 2866 this->NewExpressionList(4, zone_); | 2857 this->NewExpressionList(4, zone_); |
| 2867 Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList)); | 2858 Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList)); |
| 2868 bool done = (peek() == Token::RPAREN); | 2859 bool done = (peek() == Token::RPAREN); |
| 2869 bool was_unspread = false; | 2860 bool was_unspread = false; |
| 2870 int unspread_sequences_count = 0; | 2861 int unspread_sequences_count = 0; |
| 2871 while (!done) { | 2862 while (!done) { |
| 2872 bool is_spread = | |
| 2873 allow_harmony_spread_calls() && (peek() == Token::ELLIPSIS); | |
| 2874 int start_pos = peek_position(); | 2863 int start_pos = peek_position(); |
| 2875 if (is_spread) Consume(Token::ELLIPSIS); | 2864 bool is_spread = Check(Token::ELLIPSIS); |
| 2876 | 2865 |
| 2877 ExpressionT argument = this->ParseAssignmentExpression( | 2866 ExpressionT argument = this->ParseAssignmentExpression( |
| 2878 true, classifier, CHECK_OK_CUSTOM(NullExpressionList)); | 2867 true, classifier, CHECK_OK_CUSTOM(NullExpressionList)); |
| 2879 if (is_spread) { | 2868 if (is_spread) { |
| 2880 if (!spread_arg.IsValid()) { | 2869 if (!spread_arg.IsValid()) { |
| 2881 spread_arg.beg_pos = start_pos; | 2870 spread_arg.beg_pos = start_pos; |
| 2882 spread_arg.end_pos = peek_position(); | 2871 spread_arg.end_pos = peek_position(); |
| 2883 } | 2872 } |
| 2884 argument = factory()->NewSpread(argument, start_pos); | 2873 argument = factory()->NewSpread(argument, start_pos); |
| 2885 } | 2874 } |
| (...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4214 return; | 4203 return; |
| 4215 } | 4204 } |
| 4216 has_seen_constructor_ = true; | 4205 has_seen_constructor_ = true; |
| 4217 return; | 4206 return; |
| 4218 } | 4207 } |
| 4219 } | 4208 } |
| 4220 } // namespace internal | 4209 } // namespace internal |
| 4221 } // namespace v8 | 4210 } // namespace v8 |
| 4222 | 4211 |
| 4223 #endif // V8_PREPARSER_H | 4212 #endif // V8_PREPARSER_H |
| OLD | NEW |