| 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/func-name-inferrer.h" | 10 #include "src/func-name-inferrer.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 fni_(NULL), | 77 fni_(NULL), |
| 78 log_(log), | 78 log_(log), |
| 79 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. | 79 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. |
| 80 scanner_(scanner), | 80 scanner_(scanner), |
| 81 stack_limit_(stack_limit), | 81 stack_limit_(stack_limit), |
| 82 stack_overflow_(false), | 82 stack_overflow_(false), |
| 83 allow_lazy_(false), | 83 allow_lazy_(false), |
| 84 allow_natives_syntax_(false), | 84 allow_natives_syntax_(false), |
| 85 allow_generators_(false), | 85 allow_generators_(false), |
| 86 allow_arrow_functions_(false), | 86 allow_arrow_functions_(false), |
| 87 allow_harmony_object_literals_(false), |
| 87 zone_(zone) {} | 88 zone_(zone) {} |
| 88 | 89 |
| 89 // Getters that indicate whether certain syntactical constructs are | 90 // Getters that indicate whether certain syntactical constructs are |
| 90 // allowed to be parsed by this instance of the parser. | 91 // allowed to be parsed by this instance of the parser. |
| 91 bool allow_lazy() const { return allow_lazy_; } | 92 bool allow_lazy() const { return allow_lazy_; } |
| 92 bool allow_natives_syntax() const { return allow_natives_syntax_; } | 93 bool allow_natives_syntax() const { return allow_natives_syntax_; } |
| 93 bool allow_generators() const { return allow_generators_; } | 94 bool allow_generators() const { return allow_generators_; } |
| 94 bool allow_arrow_functions() const { return allow_arrow_functions_; } | 95 bool allow_arrow_functions() const { return allow_arrow_functions_; } |
| 95 bool allow_modules() const { return scanner()->HarmonyModules(); } | 96 bool allow_modules() const { return scanner()->HarmonyModules(); } |
| 96 bool allow_harmony_scoping() const { return scanner()->HarmonyScoping(); } | 97 bool allow_harmony_scoping() const { return scanner()->HarmonyScoping(); } |
| 97 bool allow_harmony_numeric_literals() const { | 98 bool allow_harmony_numeric_literals() const { |
| 98 return scanner()->HarmonyNumericLiterals(); | 99 return scanner()->HarmonyNumericLiterals(); |
| 99 } | 100 } |
| 100 bool allow_classes() const { return scanner()->HarmonyClasses(); } | 101 bool allow_classes() const { return scanner()->HarmonyClasses(); } |
| 102 bool allow_harmony_object_literals() const { |
| 103 return allow_harmony_object_literals_; |
| 104 } |
| 101 | 105 |
| 102 // Setters that determine whether certain syntactical constructs are | 106 // Setters that determine whether certain syntactical constructs are |
| 103 // allowed to be parsed by this instance of the parser. | 107 // allowed to be parsed by this instance of the parser. |
| 104 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } | 108 void set_allow_lazy(bool allow) { allow_lazy_ = allow; } |
| 105 void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ = allow; } | 109 void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ = allow; } |
| 106 void set_allow_generators(bool allow) { allow_generators_ = allow; } | 110 void set_allow_generators(bool allow) { allow_generators_ = allow; } |
| 107 void set_allow_arrow_functions(bool allow) { allow_arrow_functions_ = allow; } | 111 void set_allow_arrow_functions(bool allow) { allow_arrow_functions_ = allow; } |
| 108 void set_allow_modules(bool allow) { scanner()->SetHarmonyModules(allow); } | 112 void set_allow_modules(bool allow) { scanner()->SetHarmonyModules(allow); } |
| 109 void set_allow_harmony_scoping(bool allow) { | 113 void set_allow_harmony_scoping(bool allow) { |
| 110 scanner()->SetHarmonyScoping(allow); | 114 scanner()->SetHarmonyScoping(allow); |
| 111 } | 115 } |
| 112 void set_allow_harmony_numeric_literals(bool allow) { | 116 void set_allow_harmony_numeric_literals(bool allow) { |
| 113 scanner()->SetHarmonyNumericLiterals(allow); | 117 scanner()->SetHarmonyNumericLiterals(allow); |
| 114 } | 118 } |
| 115 void set_allow_classes(bool allow) { | 119 void set_allow_classes(bool allow) { scanner()->SetHarmonyClasses(allow); } |
| 116 scanner()->SetHarmonyClasses(allow); | 120 void set_allow_harmony_object_literals(bool allow) { |
| 121 allow_harmony_object_literals_ = allow; |
| 117 } | 122 } |
| 118 | 123 |
| 119 protected: | 124 protected: |
| 120 friend class Traits::Type::Checkpoint; | 125 friend class Traits::Type::Checkpoint; |
| 121 | 126 |
| 122 enum AllowEvalOrArgumentsAsIdentifier { | 127 enum AllowEvalOrArgumentsAsIdentifier { |
| 123 kAllowEvalOrArguments, | 128 kAllowEvalOrArguments, |
| 124 kDontAllowEvalOrArguments | 129 kDontAllowEvalOrArguments |
| 125 }; | 130 }; |
| 126 | 131 |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 | 519 |
| 515 private: | 520 private: |
| 516 Scanner* scanner_; | 521 Scanner* scanner_; |
| 517 uintptr_t stack_limit_; | 522 uintptr_t stack_limit_; |
| 518 bool stack_overflow_; | 523 bool stack_overflow_; |
| 519 | 524 |
| 520 bool allow_lazy_; | 525 bool allow_lazy_; |
| 521 bool allow_natives_syntax_; | 526 bool allow_natives_syntax_; |
| 522 bool allow_generators_; | 527 bool allow_generators_; |
| 523 bool allow_arrow_functions_; | 528 bool allow_arrow_functions_; |
| 529 bool allow_harmony_object_literals_; |
| 524 | 530 |
| 525 typename Traits::Type::Zone* zone_; // Only used by Parser. | 531 typename Traits::Type::Zone* zone_; // Only used by Parser. |
| 526 }; | 532 }; |
| 527 | 533 |
| 528 | 534 |
| 529 class PreParserIdentifier { | 535 class PreParserIdentifier { |
| 530 public: | 536 public: |
| 531 PreParserIdentifier() : type_(kUnknownIdentifier) {} | 537 PreParserIdentifier() : type_(kUnknownIdentifier) {} |
| 532 static PreParserIdentifier Default() { | 538 static PreParserIdentifier Default() { |
| 533 return PreParserIdentifier(kUnknownIdentifier); | 539 return PreParserIdentifier(kUnknownIdentifier); |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 } | 995 } |
| 990 PreParserExpression NewFunctionLiteral( | 996 PreParserExpression NewFunctionLiteral( |
| 991 PreParserIdentifier name, AstValueFactory* ast_value_factory, | 997 PreParserIdentifier name, AstValueFactory* ast_value_factory, |
| 992 const PreParserScope& scope, PreParserStatementList body, | 998 const PreParserScope& scope, PreParserStatementList body, |
| 993 int materialized_literal_count, int expected_property_count, | 999 int materialized_literal_count, int expected_property_count, |
| 994 int handler_count, int parameter_count, | 1000 int handler_count, int parameter_count, |
| 995 FunctionLiteral::ParameterFlag has_duplicate_parameters, | 1001 FunctionLiteral::ParameterFlag has_duplicate_parameters, |
| 996 FunctionLiteral::FunctionType function_type, | 1002 FunctionLiteral::FunctionType function_type, |
| 997 FunctionLiteral::IsFunctionFlag is_function, | 1003 FunctionLiteral::IsFunctionFlag is_function, |
| 998 FunctionLiteral::IsParenthesizedFlag is_parenthesized, | 1004 FunctionLiteral::IsParenthesizedFlag is_parenthesized, |
| 999 FunctionLiteral::KindFlag kind, int position) { | 1005 FunctionLiteral::IsGeneratorFlag is_generator, |
| 1006 FunctionLiteral::IsArrowFlag is_arrow, |
| 1007 FunctionLiteral::IsConciseMethodFlag is_concise_method, int position) { |
| 1000 return PreParserExpression::Default(); | 1008 return PreParserExpression::Default(); |
| 1001 } | 1009 } |
| 1002 | 1010 |
| 1003 // Return the object itself as AstVisitor and implement the needed | 1011 // Return the object itself as AstVisitor and implement the needed |
| 1004 // dummy method right in this class. | 1012 // dummy method right in this class. |
| 1005 PreParserFactory* visitor() { return this; } | 1013 PreParserFactory* visitor() { return this; } |
| 1006 BailoutReason dont_optimize_reason() { return kNoReason; } | 1014 BailoutReason dont_optimize_reason() { return kNoReason; } |
| 1007 int* ast_properties() { | 1015 int* ast_properties() { |
| 1008 static int dummy = 42; | 1016 static int dummy = 42; |
| 1009 return &dummy; | 1017 return &dummy; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 return 0; | 1277 return 0; |
| 1270 } | 1278 } |
| 1271 | 1279 |
| 1272 static AstValueFactory* ast_value_factory() { return NULL; } | 1280 static AstValueFactory* ast_value_factory() { return NULL; } |
| 1273 | 1281 |
| 1274 void CheckConflictingVarDeclarations(PreParserScope scope, bool* ok) {} | 1282 void CheckConflictingVarDeclarations(PreParserScope scope, bool* ok) {} |
| 1275 | 1283 |
| 1276 // Temporary glue; these functions will move to ParserBase. | 1284 // Temporary glue; these functions will move to ParserBase. |
| 1277 PreParserExpression ParseV8Intrinsic(bool* ok); | 1285 PreParserExpression ParseV8Intrinsic(bool* ok); |
| 1278 PreParserExpression ParseFunctionLiteral( | 1286 PreParserExpression ParseFunctionLiteral( |
| 1279 PreParserIdentifier name, | 1287 PreParserIdentifier name, Scanner::Location function_name_location, |
| 1280 Scanner::Location function_name_location, | |
| 1281 bool name_is_strict_reserved, | 1288 bool name_is_strict_reserved, |
| 1282 bool is_generator, | 1289 FunctionLiteral::IsGeneratorFlag is_generator, |
| 1283 int function_token_position, | 1290 FunctionLiteral::IsArrowFlag is_arrow, |
| 1284 FunctionLiteral::FunctionType type, | 1291 FunctionLiteral::IsConciseMethodFlag is_concise_method, |
| 1285 FunctionLiteral::ArityRestriction arity_restriction, | 1292 int function_token_position, FunctionLiteral::FunctionType type, |
| 1286 bool* ok); | 1293 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
| 1287 | 1294 |
| 1288 private: | 1295 private: |
| 1289 PreParser* pre_parser_; | 1296 PreParser* pre_parser_; |
| 1290 }; | 1297 }; |
| 1291 | 1298 |
| 1292 | 1299 |
| 1293 // Preparsing checks a JavaScript program and emits preparse-data that helps | 1300 // Preparsing checks a JavaScript program and emits preparse-data that helps |
| 1294 // a later parsing to be faster. | 1301 // a later parsing to be faster. |
| 1295 // See preparse-data-format.h for the data format. | 1302 // See preparse-data-format.h for the data format. |
| 1296 | 1303 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 | 1414 |
| 1408 V8_INLINE void SkipLazyFunctionBody(PreParserIdentifier function_name, | 1415 V8_INLINE void SkipLazyFunctionBody(PreParserIdentifier function_name, |
| 1409 int* materialized_literal_count, | 1416 int* materialized_literal_count, |
| 1410 int* expected_property_count, bool* ok); | 1417 int* expected_property_count, bool* ok); |
| 1411 V8_INLINE PreParserStatementList | 1418 V8_INLINE PreParserStatementList |
| 1412 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, | 1419 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, |
| 1413 Variable* fvar, Token::Value fvar_init_op, | 1420 Variable* fvar, Token::Value fvar_init_op, |
| 1414 bool is_generator, bool* ok); | 1421 bool is_generator, bool* ok); |
| 1415 | 1422 |
| 1416 Expression ParseFunctionLiteral( | 1423 Expression ParseFunctionLiteral( |
| 1417 Identifier name, | 1424 Identifier name, Scanner::Location function_name_location, |
| 1418 Scanner::Location function_name_location, | |
| 1419 bool name_is_strict_reserved, | 1425 bool name_is_strict_reserved, |
| 1420 bool is_generator, | 1426 FunctionLiteral::IsGeneratorFlag is_generator, |
| 1421 int function_token_pos, | 1427 FunctionLiteral::IsArrowFlag is_arrow, |
| 1422 FunctionLiteral::FunctionType function_type, | 1428 FunctionLiteral::IsConciseMethodFlag is_concise_method, |
| 1423 FunctionLiteral::ArityRestriction arity_restriction, | 1429 int function_token_pos, FunctionLiteral::FunctionType function_type, |
| 1424 bool* ok); | 1430 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
| 1425 void ParseLazyFunctionLiteralBody(bool* ok); | 1431 void ParseLazyFunctionLiteralBody(bool* ok); |
| 1426 | 1432 |
| 1427 bool CheckInOrOf(bool accept_OF); | 1433 bool CheckInOrOf(bool accept_OF); |
| 1428 }; | 1434 }; |
| 1429 | 1435 |
| 1430 | 1436 |
| 1431 PreParserStatementList PreParser::ParseEagerFunctionBody( | 1437 PreParserStatementList PreParser::ParseEagerFunctionBody( |
| 1432 PreParserIdentifier function_name, int pos, Variable* fvar, | 1438 PreParserIdentifier function_name, int pos, Variable* fvar, |
| 1433 Token::Value fvar_init_op, bool is_generator, bool* ok) { | 1439 Token::Value fvar_init_op, bool is_generator, bool* ok) { |
| 1434 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 1440 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 factory()); | 1832 factory()); |
| 1827 break; | 1833 break; |
| 1828 } | 1834 } |
| 1829 default: { | 1835 default: { |
| 1830 bool is_getter = false; | 1836 bool is_getter = false; |
| 1831 bool is_setter = false; | 1837 bool is_setter = false; |
| 1832 IdentifierT id = ParseIdentifierNameOrGetOrSet( | 1838 IdentifierT id = ParseIdentifierNameOrGetOrSet( |
| 1833 &is_getter, &is_setter, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1839 &is_getter, &is_setter, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 1834 if (fni_ != NULL) this->PushLiteralName(fni_, id); | 1840 if (fni_ != NULL) this->PushLiteralName(fni_, id); |
| 1835 | 1841 |
| 1836 if ((is_getter || is_setter) && peek() != Token::COLON) { | 1842 if ((is_getter || is_setter) && peek() != Token::COLON && |
| 1843 (!allow_harmony_object_literals_ || peek() != Token::LPAREN)) { |
| 1837 // Special handling of getter and setter syntax: | 1844 // Special handling of getter and setter syntax: |
| 1838 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... } | 1845 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... } |
| 1839 // We have already read the "get" or "set" keyword. | 1846 // We have already read the "get" or "set" keyword. |
| 1840 IdentifierT name = this->EmptyIdentifier(); | 1847 IdentifierT name = this->EmptyIdentifier(); |
| 1841 switch (peek()) { | 1848 switch (peek()) { |
| 1842 case Token::STRING: | 1849 case Token::STRING: |
| 1843 Consume(Token::STRING); | 1850 Consume(Token::STRING); |
| 1844 name = this->GetSymbol(scanner_); | 1851 name = this->GetSymbol(scanner()); |
| 1845 break; | 1852 break; |
| 1846 case Token::NUMBER: | 1853 case Token::NUMBER: |
| 1847 Consume(Token::NUMBER); | 1854 Consume(Token::NUMBER); |
| 1848 // TODO(arv): Fix issue with numeric keys. get 1.0() should be | 1855 // TODO(arv): Fix issue with numeric keys. get 1.0() should be |
| 1849 // treated as if the key was '1' | 1856 // treated as if the key was '1'. |
| 1850 // https://code.google.com/p/v8/issues/detail?id=3507 | 1857 // https://code.google.com/p/v8/issues/detail?id=3507 |
| 1851 name = this->GetSymbol(scanner_); | 1858 name = this->GetSymbol(scanner()); |
| 1852 break; | 1859 break; |
| 1853 default: | 1860 default: |
| 1854 name = ParseIdentifierName( | 1861 name = ParseIdentifierName( |
| 1855 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1862 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 1856 } | 1863 } |
| 1857 typename Traits::Type::FunctionLiteral value = | 1864 typename Traits::Type::FunctionLiteral value = |
| 1858 this->ParseFunctionLiteral( | 1865 this->ParseFunctionLiteral( |
| 1859 name, scanner()->location(), | 1866 name, scanner()->location(), |
| 1860 false, // reserved words are allowed here | 1867 false, // reserved words are allowed here |
| 1861 false, // not a generator | 1868 FunctionLiteral::kNotGenerator, FunctionLiteral::kNotArrow, |
| 1862 RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, | 1869 FunctionLiteral::kNotConciseMethod, RelocInfo::kNoPosition, |
| 1870 FunctionLiteral::ANONYMOUS_EXPRESSION, |
| 1863 is_getter ? FunctionLiteral::GETTER_ARITY | 1871 is_getter ? FunctionLiteral::GETTER_ARITY |
| 1864 : FunctionLiteral::SETTER_ARITY, | 1872 : FunctionLiteral::SETTER_ARITY, |
| 1865 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1873 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 1866 return factory()->NewObjectLiteralProperty(is_getter, value, next_pos); | 1874 return factory()->NewObjectLiteralProperty(is_getter, value, next_pos); |
| 1867 } | 1875 } |
| 1868 // Failed to parse as get/set property, so it's just a normal property | 1876 // Failed to parse as get/set property, so it's just a normal property |
| 1869 // (which might be called "get" or "set" or something else). | 1877 // (which might be called "get" or "set" or something else). |
| 1870 key = factory()->NewStringLiteral(id, next_pos); | 1878 key = factory()->NewStringLiteral(id, next_pos); |
| 1871 } | 1879 } |
| 1872 } | 1880 } |
| 1873 | 1881 |
| 1874 Expect(Token::COLON, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1882 ExpressionT value = this->EmptyExpression(); |
| 1875 ExpressionT value = this->ParseAssignmentExpression( | 1883 |
| 1876 true, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1884 if (allow_harmony_object_literals_ && peek() == Token::LPAREN) { |
| 1885 // TODO(arv): Parameters should use StrictFormalParameters. |
| 1886 // TODO(arv): If the FunctionBody references super we need to call |
| 1887 // MakeMethod. |
| 1888 |
| 1889 // TODO(arv): Fix issue with numeric keys. 1.0() should be treated as if the |
| 1890 // key was '1'. |
| 1891 // https://code.google.com/p/v8/issues/detail?id=3507 |
| 1892 IdentifierT name = this->GetSymbol(scanner()); |
| 1893 |
| 1894 value = this->ParseFunctionLiteral( |
| 1895 name, scanner()->location(), |
| 1896 false, // reserved words are allowed here |
| 1897 FunctionLiteral::kNotGenerator, FunctionLiteral::kNotArrow, |
| 1898 FunctionLiteral::kIsConciseMethod, RelocInfo::kNoPosition, |
| 1899 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::NORMAL_ARITY, |
| 1900 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 1901 } else { |
| 1902 Expect(Token::COLON, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 1903 value = this->ParseAssignmentExpression( |
| 1904 true, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 1905 } |
| 1877 | 1906 |
| 1878 return factory()->NewObjectLiteralProperty(key, value); | 1907 return factory()->NewObjectLiteralProperty(key, value); |
| 1879 } | 1908 } |
| 1880 | 1909 |
| 1881 | 1910 |
| 1882 template <class Traits> | 1911 template <class Traits> |
| 1883 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseObjectLiteral( | 1912 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseObjectLiteral( |
| 1884 bool* ok) { | 1913 bool* ok) { |
| 1885 // ObjectLiteral :: | 1914 // ObjectLiteral :: |
| 1886 // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}' | 1915 // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}' |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2362 bool is_strict_reserved_name = false; | 2391 bool is_strict_reserved_name = false; |
| 2363 Scanner::Location function_name_location = Scanner::Location::invalid(); | 2392 Scanner::Location function_name_location = Scanner::Location::invalid(); |
| 2364 FunctionLiteral::FunctionType function_type = | 2393 FunctionLiteral::FunctionType function_type = |
| 2365 FunctionLiteral::ANONYMOUS_EXPRESSION; | 2394 FunctionLiteral::ANONYMOUS_EXPRESSION; |
| 2366 if (peek_any_identifier()) { | 2395 if (peek_any_identifier()) { |
| 2367 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name, | 2396 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name, |
| 2368 CHECK_OK); | 2397 CHECK_OK); |
| 2369 function_name_location = scanner()->location(); | 2398 function_name_location = scanner()->location(); |
| 2370 function_type = FunctionLiteral::NAMED_EXPRESSION; | 2399 function_type = FunctionLiteral::NAMED_EXPRESSION; |
| 2371 } | 2400 } |
| 2372 result = this->ParseFunctionLiteral(name, | 2401 result = this->ParseFunctionLiteral( |
| 2373 function_name_location, | 2402 name, function_name_location, is_strict_reserved_name, |
| 2374 is_strict_reserved_name, | 2403 is_generator ? FunctionLiteral::kIsGenerator |
| 2375 is_generator, | 2404 : FunctionLiteral::kNotGenerator, |
| 2376 function_token_position, | 2405 FunctionLiteral::kNotArrow, FunctionLiteral::kNotConciseMethod, |
| 2377 function_type, | 2406 function_token_position, function_type, FunctionLiteral::NORMAL_ARITY, |
| 2378 FunctionLiteral::NORMAL_ARITY, | 2407 CHECK_OK); |
| 2379 CHECK_OK); | |
| 2380 } else if (peek() == Token::SUPER) { | 2408 } else if (peek() == Token::SUPER) { |
| 2381 int beg_pos = position(); | 2409 int beg_pos = position(); |
| 2382 Consume(Token::SUPER); | 2410 Consume(Token::SUPER); |
| 2383 Token::Value next = peek(); | 2411 Token::Value next = peek(); |
| 2384 if (next == Token::PERIOD || next == Token::LBRACK || | 2412 if (next == Token::PERIOD || next == Token::LBRACK || |
| 2385 next == Token::LPAREN) { | 2413 next == Token::LPAREN) { |
| 2386 result = this->SuperReference(scope_, factory()); | 2414 result = this->SuperReference(scope_, factory()); |
| 2387 } else { | 2415 } else { |
| 2388 ReportMessageAt(Scanner::Location(beg_pos, position()), | 2416 ReportMessageAt(Scanner::Location(beg_pos, position()), |
| 2389 "unexpected_super"); | 2417 "unexpected_super"); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2530 | 2558 |
| 2531 ast_properties = *factory()->visitor()->ast_properties(); | 2559 ast_properties = *factory()->visitor()->ast_properties(); |
| 2532 dont_optimize_reason = factory()->visitor()->dont_optimize_reason(); | 2560 dont_optimize_reason = factory()->visitor()->dont_optimize_reason(); |
| 2533 } | 2561 } |
| 2534 | 2562 |
| 2535 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( | 2563 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( |
| 2536 this->EmptyIdentifierString(), this->ast_value_factory(), scope, body, | 2564 this->EmptyIdentifierString(), this->ast_value_factory(), scope, body, |
| 2537 materialized_literal_count, expected_property_count, handler_count, | 2565 materialized_literal_count, expected_property_count, handler_count, |
| 2538 num_parameters, FunctionLiteral::kNoDuplicateParameters, | 2566 num_parameters, FunctionLiteral::kNoDuplicateParameters, |
| 2539 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, | 2567 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, |
| 2540 FunctionLiteral::kNotParenthesized, FunctionLiteral::kArrowFunction, | 2568 FunctionLiteral::kNotParenthesized, FunctionLiteral::kNotGenerator, |
| 2541 start_pos); | 2569 FunctionLiteral::kIsArrow, FunctionLiteral::kNotConciseMethod, start_pos); |
| 2542 | 2570 |
| 2543 function_literal->set_function_token_position(start_pos); | 2571 function_literal->set_function_token_position(start_pos); |
| 2544 function_literal->set_ast_properties(&ast_properties); | 2572 function_literal->set_ast_properties(&ast_properties); |
| 2545 function_literal->set_dont_optimize_reason(dont_optimize_reason); | 2573 function_literal->set_dont_optimize_reason(dont_optimize_reason); |
| 2546 | 2574 |
| 2547 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); | 2575 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); |
| 2548 | 2576 |
| 2549 return function_literal; | 2577 return function_literal; |
| 2550 } | 2578 } |
| 2551 | 2579 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2576 } | 2604 } |
| 2577 | 2605 |
| 2578 | 2606 |
| 2579 #undef CHECK_OK | 2607 #undef CHECK_OK |
| 2580 #undef CHECK_OK_CUSTOM | 2608 #undef CHECK_OK_CUSTOM |
| 2581 | 2609 |
| 2582 | 2610 |
| 2583 } } // v8::internal | 2611 } } // v8::internal |
| 2584 | 2612 |
| 2585 #endif // V8_PREPARSER_H | 2613 #endif // V8_PREPARSER_H |
| OLD | NEW |