Chromium Code Reviews| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 class ParserBase : public Traits { | 81 class ParserBase : public Traits { |
| 82 public: | 82 public: |
| 83 // Shorten type names defined by Traits. | 83 // Shorten type names defined by Traits. |
| 84 typedef typename Traits::Type::Expression ExpressionT; | 84 typedef typename Traits::Type::Expression ExpressionT; |
| 85 typedef typename Traits::Type::Identifier IdentifierT; | 85 typedef typename Traits::Type::Identifier IdentifierT; |
| 86 typedef typename Traits::Type::FormalParameter FormalParameterT; | 86 typedef typename Traits::Type::FormalParameter FormalParameterT; |
| 87 typedef typename Traits::Type::FormalParameters FormalParametersT; | 87 typedef typename Traits::Type::FormalParameters FormalParametersT; |
| 88 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; | 88 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; |
| 89 typedef typename Traits::Type::Literal LiteralT; | 89 typedef typename Traits::Type::Literal LiteralT; |
| 90 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; | 90 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; |
| 91 typedef typename Traits::Type::StatementList StatementListT; | |
| 91 | 92 |
| 92 ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit, | 93 ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit, |
| 93 v8::Extension* extension, AstValueFactory* ast_value_factory, | 94 v8::Extension* extension, AstValueFactory* ast_value_factory, |
| 94 ParserRecorder* log, typename Traits::Type::Parser this_object) | 95 ParserRecorder* log, typename Traits::Type::Parser this_object) |
| 95 : Traits(this_object), | 96 : Traits(this_object), |
| 96 parenthesized_function_(false), | 97 parenthesized_function_(false), |
| 97 scope_(NULL), | 98 scope_(NULL), |
| 98 function_state_(NULL), | 99 function_state_(NULL), |
| 99 extension_(extension), | 100 extension_(extension), |
| 100 fni_(NULL), | 101 fni_(NULL), |
| 101 ast_value_factory_(ast_value_factory), | 102 ast_value_factory_(ast_value_factory), |
| 102 log_(log), | 103 log_(log), |
| 103 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. | 104 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. |
| 104 stack_limit_(stack_limit), | 105 stack_limit_(stack_limit), |
| 105 zone_(zone), | 106 zone_(zone), |
| 106 scanner_(scanner), | 107 scanner_(scanner), |
| 107 stack_overflow_(false), | 108 stack_overflow_(false), |
| 108 allow_lazy_(false), | 109 allow_lazy_(false), |
| 109 allow_natives_(false), | 110 allow_natives_(false), |
| 110 allow_harmony_sloppy_(false), | 111 allow_harmony_sloppy_(false), |
| 111 allow_harmony_sloppy_function_(false), | 112 allow_harmony_sloppy_function_(false), |
| 112 allow_harmony_sloppy_let_(false), | 113 allow_harmony_sloppy_let_(false), |
| 113 allow_harmony_rest_parameters_(false), | 114 allow_harmony_rest_parameters_(false), |
| 114 allow_harmony_default_parameters_(false), | 115 allow_harmony_default_parameters_(false), |
| 115 allow_harmony_spread_calls_(false), | 116 allow_harmony_spread_calls_(false), |
| 116 allow_harmony_destructuring_(false), | 117 allow_harmony_destructuring_(false), |
| 117 allow_harmony_spread_arrays_(false), | 118 allow_harmony_spread_arrays_(false), |
| 118 allow_harmony_new_target_(false), | 119 allow_harmony_new_target_(false), |
| 119 allow_strong_mode_(false), | 120 allow_strong_mode_(false), |
| 120 allow_legacy_const_(true) {} | 121 allow_legacy_const_(true), |
| 122 allow_do_expression_parsing_(false) {} | |
| 121 | 123 |
| 122 #define ALLOW_ACCESSORS(name) \ | 124 #define ALLOW_ACCESSORS(name) \ |
| 123 bool allow_##name() const { return allow_##name##_; } \ | 125 bool allow_##name() const { return allow_##name##_; } \ |
| 124 void set_allow_##name(bool allow) { allow_##name##_ = allow; } | 126 void set_allow_##name(bool allow) { allow_##name##_ = allow; } |
| 125 | 127 |
| 126 ALLOW_ACCESSORS(lazy); | 128 ALLOW_ACCESSORS(lazy); |
| 127 ALLOW_ACCESSORS(natives); | 129 ALLOW_ACCESSORS(natives); |
| 128 ALLOW_ACCESSORS(harmony_sloppy); | 130 ALLOW_ACCESSORS(harmony_sloppy); |
| 129 ALLOW_ACCESSORS(harmony_sloppy_function); | 131 ALLOW_ACCESSORS(harmony_sloppy_function); |
| 130 ALLOW_ACCESSORS(harmony_sloppy_let); | 132 ALLOW_ACCESSORS(harmony_sloppy_let); |
| 131 ALLOW_ACCESSORS(harmony_rest_parameters); | 133 ALLOW_ACCESSORS(harmony_rest_parameters); |
| 132 ALLOW_ACCESSORS(harmony_default_parameters); | 134 ALLOW_ACCESSORS(harmony_default_parameters); |
| 133 ALLOW_ACCESSORS(harmony_spread_calls); | 135 ALLOW_ACCESSORS(harmony_spread_calls); |
| 134 ALLOW_ACCESSORS(harmony_destructuring); | 136 ALLOW_ACCESSORS(harmony_destructuring); |
| 135 ALLOW_ACCESSORS(harmony_spread_arrays); | 137 ALLOW_ACCESSORS(harmony_spread_arrays); |
| 136 ALLOW_ACCESSORS(harmony_new_target); | 138 ALLOW_ACCESSORS(harmony_new_target); |
| 137 ALLOW_ACCESSORS(strong_mode); | 139 ALLOW_ACCESSORS(strong_mode); |
| 138 ALLOW_ACCESSORS(legacy_const); | 140 ALLOW_ACCESSORS(legacy_const); |
| 141 ALLOW_ACCESSORS(do_expression_parsing); | |
| 139 #undef ALLOW_ACCESSORS | 142 #undef ALLOW_ACCESSORS |
| 140 | 143 |
| 144 INLINE(bool CheckStackOverflow()) { | |
| 145 if (stack_overflow_) return true; | |
| 146 if (GetCurrentStackPosition() >= stack_limit_) return false; | |
| 147 stack_overflow_ = true; | |
| 148 return true; | |
| 149 } | |
| 150 | |
| 141 protected: | 151 protected: |
| 142 enum AllowRestrictedIdentifiers { | 152 enum AllowRestrictedIdentifiers { |
| 143 kAllowRestrictedIdentifiers, | 153 kAllowRestrictedIdentifiers, |
| 144 kDontAllowRestrictedIdentifiers | 154 kDontAllowRestrictedIdentifiers |
| 145 }; | 155 }; |
| 146 | 156 |
| 147 enum Mode { | 157 enum Mode { |
| 148 PARSE_LAZILY, | 158 PARSE_LAZILY, |
| 149 PARSE_EAGERLY | 159 PARSE_EAGERLY |
| 150 }; | 160 }; |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 | 686 |
| 677 | 687 |
| 678 ExpressionT ParseRegExpLiteral(bool seen_equal, | 688 ExpressionT ParseRegExpLiteral(bool seen_equal, |
| 679 ExpressionClassifier* classifier, bool* ok); | 689 ExpressionClassifier* classifier, bool* ok); |
| 680 | 690 |
| 681 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier, | 691 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier, |
| 682 bool* ok); | 692 bool* ok); |
| 683 ExpressionT ParseExpression(bool accept_IN, bool* ok); | 693 ExpressionT ParseExpression(bool accept_IN, bool* ok); |
| 684 ExpressionT ParseExpression(bool accept_IN, ExpressionClassifier* classifier, | 694 ExpressionT ParseExpression(bool accept_IN, ExpressionClassifier* classifier, |
| 685 bool* ok); | 695 bool* ok); |
| 696 ExpressionT ParseDoExpression(bool* ok); | |
| 686 ExpressionT ParseArrayLiteral(ExpressionClassifier* classifier, bool* ok); | 697 ExpressionT ParseArrayLiteral(ExpressionClassifier* classifier, bool* ok); |
| 687 ExpressionT ParsePropertyName(IdentifierT* name, bool* is_get, bool* is_set, | 698 ExpressionT ParsePropertyName(IdentifierT* name, bool* is_get, bool* is_set, |
| 688 bool* is_static, bool* is_computed_name, | 699 bool* is_static, bool* is_computed_name, |
| 689 ExpressionClassifier* classifier, bool* ok); | 700 ExpressionClassifier* classifier, bool* ok); |
| 690 ExpressionT ParseObjectLiteral(ExpressionClassifier* classifier, bool* ok); | 701 ExpressionT ParseObjectLiteral(ExpressionClassifier* classifier, bool* ok); |
| 691 ObjectLiteralPropertyT ParsePropertyDefinition( | 702 ObjectLiteralPropertyT ParsePropertyDefinition( |
| 692 ObjectLiteralCheckerBase* checker, bool in_class, bool has_extends, | 703 ObjectLiteralCheckerBase* checker, bool in_class, bool has_extends, |
| 693 bool is_static, bool* is_computed_name, bool* has_seen_constructor, | 704 bool is_static, bool* is_computed_name, bool* has_seen_constructor, |
| 694 ExpressionClassifier* classifier, bool* ok); | 705 ExpressionClassifier* classifier, bool* ok); |
| 695 typename Traits::Type::ExpressionList ParseArguments( | 706 typename Traits::Type::ExpressionList ParseArguments( |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 bool allow_harmony_sloppy_function_; | 845 bool allow_harmony_sloppy_function_; |
| 835 bool allow_harmony_sloppy_let_; | 846 bool allow_harmony_sloppy_let_; |
| 836 bool allow_harmony_rest_parameters_; | 847 bool allow_harmony_rest_parameters_; |
| 837 bool allow_harmony_default_parameters_; | 848 bool allow_harmony_default_parameters_; |
| 838 bool allow_harmony_spread_calls_; | 849 bool allow_harmony_spread_calls_; |
| 839 bool allow_harmony_destructuring_; | 850 bool allow_harmony_destructuring_; |
| 840 bool allow_harmony_spread_arrays_; | 851 bool allow_harmony_spread_arrays_; |
| 841 bool allow_harmony_new_target_; | 852 bool allow_harmony_new_target_; |
| 842 bool allow_strong_mode_; | 853 bool allow_strong_mode_; |
| 843 bool allow_legacy_const_; | 854 bool allow_legacy_const_; |
| 855 bool allow_do_expression_parsing_; | |
| 844 }; | 856 }; |
| 845 | 857 |
| 846 | 858 |
| 847 class PreParserIdentifier { | 859 class PreParserIdentifier { |
| 848 public: | 860 public: |
| 849 PreParserIdentifier() : type_(kUnknownIdentifier) {} | 861 PreParserIdentifier() : type_(kUnknownIdentifier) {} |
| 850 static PreParserIdentifier Default() { | 862 static PreParserIdentifier Default() { |
| 851 return PreParserIdentifier(kUnknownIdentifier); | 863 return PreParserIdentifier(kUnknownIdentifier); |
| 852 } | 864 } |
| 853 static PreParserIdentifier Eval() { | 865 static PreParserIdentifier Eval() { |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1344 } | 1356 } |
| 1345 | 1357 |
| 1346 PreParserExpression NewSpread(PreParserExpression expression, int pos) { | 1358 PreParserExpression NewSpread(PreParserExpression expression, int pos) { |
| 1347 return PreParserExpression::Spread(expression); | 1359 return PreParserExpression::Spread(expression); |
| 1348 } | 1360 } |
| 1349 | 1361 |
| 1350 PreParserExpression NewEmptyParentheses(int pos) { | 1362 PreParserExpression NewEmptyParentheses(int pos) { |
| 1351 return PreParserExpression::Default(); | 1363 return PreParserExpression::Default(); |
| 1352 } | 1364 } |
| 1353 | 1365 |
| 1366 PreParserExpression NewDoExpression(Scope* scope, | |
| 1367 PreParserStatementList statements, | |
| 1368 int pos, int end_pos) { | |
| 1369 return PreParserExpression::Default(); | |
| 1370 } | |
| 1371 | |
| 1354 // Return the object itself as AstVisitor and implement the needed | 1372 // Return the object itself as AstVisitor and implement the needed |
| 1355 // dummy method right in this class. | 1373 // dummy method right in this class. |
| 1356 PreParserFactory* visitor() { return this; } | 1374 PreParserFactory* visitor() { return this; } |
| 1357 int* ast_properties() { | 1375 int* ast_properties() { |
| 1358 static int dummy = 42; | 1376 static int dummy = 42; |
| 1359 return &dummy; | 1377 return &dummy; |
| 1360 } | 1378 } |
| 1361 }; | 1379 }; |
| 1362 | 1380 |
| 1363 | 1381 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1697 | 1715 |
| 1698 // Temporary glue; these functions will move to ParserBase. | 1716 // Temporary glue; these functions will move to ParserBase. |
| 1699 PreParserExpression ParseV8Intrinsic(bool* ok); | 1717 PreParserExpression ParseV8Intrinsic(bool* ok); |
| 1700 PreParserExpression ParseFunctionLiteral( | 1718 PreParserExpression ParseFunctionLiteral( |
| 1701 PreParserIdentifier name, Scanner::Location function_name_location, | 1719 PreParserIdentifier name, Scanner::Location function_name_location, |
| 1702 FunctionNameValidity function_name_validity, FunctionKind kind, | 1720 FunctionNameValidity function_name_validity, FunctionKind kind, |
| 1703 int function_token_position, FunctionLiteral::FunctionType type, | 1721 int function_token_position, FunctionLiteral::FunctionType type, |
| 1704 FunctionLiteral::ArityRestriction arity_restriction, | 1722 FunctionLiteral::ArityRestriction arity_restriction, |
| 1705 LanguageMode language_mode, bool* ok); | 1723 LanguageMode language_mode, bool* ok); |
| 1706 | 1724 |
| 1725 inline PreParserStatementList ParseStatementList(Token::Value end_token, | |
| 1726 bool* ok); | |
| 1727 | |
| 1707 PreParserExpression ParseClassLiteral(PreParserIdentifier name, | 1728 PreParserExpression ParseClassLiteral(PreParserIdentifier name, |
| 1708 Scanner::Location class_name_location, | 1729 Scanner::Location class_name_location, |
| 1709 bool name_is_strict_reserved, int pos, | 1730 bool name_is_strict_reserved, int pos, |
| 1710 bool* ok); | 1731 bool* ok); |
| 1711 | 1732 |
| 1712 PreParserExpressionList PrepareSpreadArguments(PreParserExpressionList list) { | 1733 PreParserExpressionList PrepareSpreadArguments(PreParserExpressionList list) { |
| 1713 return list; | 1734 return list; |
| 1714 } | 1735 } |
| 1715 | 1736 |
| 1716 inline void MaterializeUnspreadArgumentsLiterals(int count); | 1737 inline void MaterializeUnspreadArgumentsLiterals(int count); |
| 1717 | 1738 |
| 1718 inline PreParserExpression SpreadCall(PreParserExpression function, | 1739 inline PreParserExpression SpreadCall(PreParserExpression function, |
| 1719 PreParserExpressionList args, int pos); | 1740 PreParserExpressionList args, int pos); |
| 1720 | 1741 |
| 1721 inline PreParserExpression SpreadCallNew(PreParserExpression function, | 1742 inline PreParserExpression SpreadCallNew(PreParserExpression function, |
| 1722 PreParserExpressionList args, | 1743 PreParserExpressionList args, |
| 1723 int pos); | 1744 int pos); |
| 1724 | 1745 |
| 1746 inline void RewriteDoExpression(PreParserExpression expr, bool* ok) {} | |
| 1747 | |
| 1725 private: | 1748 private: |
| 1726 PreParser* pre_parser_; | 1749 PreParser* pre_parser_; |
| 1727 }; | 1750 }; |
| 1728 | 1751 |
| 1729 | 1752 |
| 1730 // Preparsing checks a JavaScript program and emits preparse-data that helps | 1753 // Preparsing checks a JavaScript program and emits preparse-data that helps |
| 1731 // a later parsing to be faster. | 1754 // a later parsing to be faster. |
| 1732 // See preparse-data-format.h for the data format. | 1755 // See preparse-data-format.h for the data format. |
| 1733 | 1756 |
| 1734 // The PreParser checks that the syntax follows the grammar for JavaScript, | 1757 // The PreParser checks that the syntax follows the grammar for JavaScript, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1918 | 1941 |
| 1919 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( | 1942 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( |
| 1920 PreParserIdentifier function_name, int pos, | 1943 PreParserIdentifier function_name, int pos, |
| 1921 const PreParserFormalParameters& parameters, FunctionKind kind, | 1944 const PreParserFormalParameters& parameters, FunctionKind kind, |
| 1922 FunctionLiteral::FunctionType function_type, bool* ok) { | 1945 FunctionLiteral::FunctionType function_type, bool* ok) { |
| 1923 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, | 1946 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, |
| 1924 kind, function_type, ok); | 1947 kind, function_type, ok); |
| 1925 } | 1948 } |
| 1926 | 1949 |
| 1927 | 1950 |
| 1951 inline PreParserStatementList PreParserTraits::ParseStatementList( | |
| 1952 Token::Value end_token, bool* ok) { | |
| 1953 pre_parser_->ParseStatementList(end_token, ok); | |
| 1954 return PreParserStatementList(); | |
| 1955 } | |
| 1956 | |
| 1957 | |
| 1928 template <class Traits> | 1958 template <class Traits> |
| 1929 ParserBase<Traits>::FunctionState::FunctionState( | 1959 ParserBase<Traits>::FunctionState::FunctionState( |
| 1930 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope, | 1960 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope, |
| 1931 FunctionKind kind, typename Traits::Type::Factory* factory) | 1961 FunctionKind kind, typename Traits::Type::Factory* factory) |
| 1932 : next_materialized_literal_index_(0), | 1962 : next_materialized_literal_index_(0), |
| 1933 expected_property_count_(0), | 1963 expected_property_count_(0), |
| 1934 this_location_(Scanner::Location::invalid()), | 1964 this_location_(Scanner::Location::invalid()), |
| 1935 return_location_(Scanner::Location::invalid()), | 1965 return_location_(Scanner::Location::invalid()), |
| 1936 super_location_(Scanner::Location::invalid()), | 1966 super_location_(Scanner::Location::invalid()), |
| 1937 kind_(kind), | 1967 kind_(kind), |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2215 // 'false' | 2245 // 'false' |
| 2216 // Identifier | 2246 // Identifier |
| 2217 // Number | 2247 // Number |
| 2218 // String | 2248 // String |
| 2219 // ArrayLiteral | 2249 // ArrayLiteral |
| 2220 // ObjectLiteral | 2250 // ObjectLiteral |
| 2221 // RegExpLiteral | 2251 // RegExpLiteral |
| 2222 // ClassLiteral | 2252 // ClassLiteral |
| 2223 // '(' Expression ')' | 2253 // '(' Expression ')' |
| 2224 // TemplateLiteral | 2254 // TemplateLiteral |
| 2255 // do Block | |
| 2225 | 2256 |
| 2226 int beg_pos = scanner()->peek_location().beg_pos; | 2257 int beg_pos = scanner()->peek_location().beg_pos; |
| 2227 int end_pos = scanner()->peek_location().end_pos; | 2258 int end_pos = scanner()->peek_location().end_pos; |
| 2228 ExpressionT result = this->EmptyExpression(); | 2259 ExpressionT result = this->EmptyExpression(); |
| 2229 Token::Value token = peek(); | 2260 Token::Value token = peek(); |
| 2230 switch (token) { | 2261 switch (token) { |
| 2231 case Token::THIS: { | 2262 case Token::THIS: { |
| 2232 BindingPatternUnexpectedToken(classifier); | 2263 BindingPatternUnexpectedToken(classifier); |
| 2233 Consume(Token::THIS); | 2264 Consume(Token::THIS); |
| 2234 if (FLAG_strong_this && is_strong(language_mode())) { | 2265 if (FLAG_strong_this && is_strong(language_mode())) { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2395 MessageTemplate::kUnexpectedTemplateString); | 2426 MessageTemplate::kUnexpectedTemplateString); |
| 2396 result = this->ParseTemplateLiteral(Traits::NoTemplateTag(), beg_pos, | 2427 result = this->ParseTemplateLiteral(Traits::NoTemplateTag(), beg_pos, |
| 2397 classifier, CHECK_OK); | 2428 classifier, CHECK_OK); |
| 2398 break; | 2429 break; |
| 2399 | 2430 |
| 2400 case Token::MOD: | 2431 case Token::MOD: |
| 2401 if (allow_natives() || extension_ != NULL) { | 2432 if (allow_natives() || extension_ != NULL) { |
| 2402 result = this->ParseV8Intrinsic(CHECK_OK); | 2433 result = this->ParseV8Intrinsic(CHECK_OK); |
| 2403 break; | 2434 break; |
| 2404 } | 2435 } |
| 2436 | |
| 2437 case Token::DO: | |
| 2438 if (token == Token::DO && allow_do_expression_parsing()) { | |
| 2439 BindingPatternUnexpectedToken(classifier); | |
| 2440 result = this->ParseDoExpression(ok); | |
| 2441 break; | |
| 2442 } | |
| 2405 // If we're not allowing special syntax we fall-through to the | 2443 // If we're not allowing special syntax we fall-through to the |
| 2406 // default case. | 2444 // default case. |
| 2407 | 2445 |
| 2408 default: { | 2446 default: { |
| 2409 Next(); | 2447 Next(); |
| 2410 ReportUnexpectedToken(token); | 2448 ReportUnexpectedToken(token); |
| 2411 *ok = false; | 2449 *ok = false; |
| 2412 } | 2450 } |
| 2413 } | 2451 } |
| 2414 | 2452 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2470 result = factory()->NewBinaryOperation(Token::COMMA, result, right, pos); | 2508 result = factory()->NewBinaryOperation(Token::COMMA, result, right, pos); |
| 2471 } | 2509 } |
| 2472 if (!is_simple_parameter_list || seen_rest) { | 2510 if (!is_simple_parameter_list || seen_rest) { |
| 2473 classifier->RecordNonSimpleParameter(); | 2511 classifier->RecordNonSimpleParameter(); |
| 2474 } | 2512 } |
| 2475 return result; | 2513 return result; |
| 2476 } | 2514 } |
| 2477 | 2515 |
| 2478 | 2516 |
| 2479 template <class Traits> | 2517 template <class Traits> |
| 2518 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseDoExpression( | |
| 2519 bool* ok) { | |
| 2520 // AssignmentExpression :: | |
| 2521 // do '{' StatementList '}' | |
| 2522 int pos = peek_position(); | |
| 2523 Expect(Token::DO, CHECK_OK); | |
| 2524 Expect(Token::LBRACE, CHECK_OK); | |
|
rossberg
2015/10/12 13:52:40
Can't you just invoke ParseScopedBlock here?
caitp (gmail)
2015/10/12 18:23:00
Done, sort of.
ParseScopedBlock only exists in th
| |
| 2525 Scope* block_scope = NewScope(scope_, BLOCK_SCOPE); | |
| 2526 { | |
| 2527 BlockState block_state(&scope_, block_scope); | |
| 2528 StatementListT statements = | |
| 2529 Traits::ParseStatementList(Token::RBRACE, CHECK_OK); | |
| 2530 Expect(Token::RBRACE, CHECK_OK); | |
| 2531 int end_pos = scanner()->location().end_pos; | |
| 2532 block_scope->set_start_position(pos); | |
| 2533 block_scope->set_end_position(end_pos); | |
| 2534 ExpressionT expr = | |
| 2535 factory()->NewDoExpression(block_scope, statements, pos, end_pos); | |
| 2536 Traits::RewriteDoExpression(expr, CHECK_OK); | |
| 2537 return expr; | |
| 2538 } | |
| 2539 } | |
| 2540 | |
| 2541 | |
| 2542 template <class Traits> | |
| 2480 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseArrayLiteral( | 2543 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseArrayLiteral( |
| 2481 ExpressionClassifier* classifier, bool* ok) { | 2544 ExpressionClassifier* classifier, bool* ok) { |
| 2482 // ArrayLiteral :: | 2545 // ArrayLiteral :: |
| 2483 // '[' Expression? (',' Expression?)* ']' | 2546 // '[' Expression? (',' Expression?)* ']' |
| 2484 | 2547 |
| 2485 int pos = peek_position(); | 2548 int pos = peek_position(); |
| 2486 typename Traits::Type::ExpressionList values = | 2549 typename Traits::Type::ExpressionList values = |
| 2487 this->NewExpressionList(4, zone_); | 2550 this->NewExpressionList(4, zone_); |
| 2488 int first_spread_index = -1; | 2551 int first_spread_index = -1; |
| 2489 Expect(Token::LBRACK, CHECK_OK); | 2552 Expect(Token::LBRACK, CHECK_OK); |
| (...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4186 return; | 4249 return; |
| 4187 } | 4250 } |
| 4188 has_seen_constructor_ = true; | 4251 has_seen_constructor_ = true; |
| 4189 return; | 4252 return; |
| 4190 } | 4253 } |
| 4191 } | 4254 } |
| 4192 } // namespace internal | 4255 } // namespace internal |
| 4193 } // namespace v8 | 4256 } // namespace v8 |
| 4194 | 4257 |
| 4195 #endif // V8_PREPARSER_H | 4258 #endif // V8_PREPARSER_H |
| OLD | NEW |