Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/preparser.h

Issue 477263002: ES6: Add support for method shorthand in object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add strict formal param checking Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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::Checkpoint; 125 friend class Traits::Checkpoint;
121 126
122 enum AllowEvalOrArgumentsAsIdentifier { 127 enum AllowEvalOrArgumentsAsIdentifier {
123 kAllowEvalOrArguments, 128 kAllowEvalOrArguments,
124 kDontAllowEvalOrArguments 129 kDontAllowEvalOrArguments
125 }; 130 };
126 131
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 572
568 private: 573 private:
569 Scanner* scanner_; 574 Scanner* scanner_;
570 uintptr_t stack_limit_; 575 uintptr_t stack_limit_;
571 bool stack_overflow_; 576 bool stack_overflow_;
572 577
573 bool allow_lazy_; 578 bool allow_lazy_;
574 bool allow_natives_syntax_; 579 bool allow_natives_syntax_;
575 bool allow_generators_; 580 bool allow_generators_;
576 bool allow_arrow_functions_; 581 bool allow_arrow_functions_;
582 bool allow_harmony_object_literals_;
577 583
578 typename Traits::Type::Zone* zone_; // Only used by Parser. 584 typename Traits::Type::Zone* zone_; // Only used by Parser.
579 }; 585 };
580 586
581 587
582 class PreParserIdentifier { 588 class PreParserIdentifier {
583 public: 589 public:
584 PreParserIdentifier() : type_(kUnknownIdentifier) {} 590 PreParserIdentifier() : type_(kUnknownIdentifier) {}
585 static PreParserIdentifier Default() { 591 static PreParserIdentifier Default() {
586 return PreParserIdentifier(kUnknownIdentifier); 592 return PreParserIdentifier(kUnknownIdentifier);
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 } 1048 }
1043 PreParserExpression NewFunctionLiteral( 1049 PreParserExpression NewFunctionLiteral(
1044 PreParserIdentifier name, AstValueFactory* ast_value_factory, 1050 PreParserIdentifier name, AstValueFactory* ast_value_factory,
1045 const PreParserScope& scope, PreParserStatementList body, 1051 const PreParserScope& scope, PreParserStatementList body,
1046 int materialized_literal_count, int expected_property_count, 1052 int materialized_literal_count, int expected_property_count,
1047 int handler_count, int parameter_count, 1053 int handler_count, int parameter_count,
1048 FunctionLiteral::ParameterFlag has_duplicate_parameters, 1054 FunctionLiteral::ParameterFlag has_duplicate_parameters,
1049 FunctionLiteral::FunctionType function_type, 1055 FunctionLiteral::FunctionType function_type,
1050 FunctionLiteral::IsFunctionFlag is_function, 1056 FunctionLiteral::IsFunctionFlag is_function,
1051 FunctionLiteral::IsParenthesizedFlag is_parenthesized, 1057 FunctionLiteral::IsParenthesizedFlag is_parenthesized,
1052 FunctionLiteral::KindFlag kind, int position) { 1058 FunctionLiteral::IsGeneratorFlag is_generator,
1059 FunctionLiteral::IsArrowFlag is_arrow,
1060 FunctionLiteral::IsConciseMethodFlag is_concise_method, int position) {
1053 return PreParserExpression::Default(); 1061 return PreParserExpression::Default();
1054 } 1062 }
1055 1063
1056 // Return the object itself as AstVisitor and implement the needed 1064 // Return the object itself as AstVisitor and implement the needed
1057 // dummy method right in this class. 1065 // dummy method right in this class.
1058 PreParserFactory* visitor() { return this; } 1066 PreParserFactory* visitor() { return this; }
1059 BailoutReason dont_optimize_reason() { return kNoReason; } 1067 BailoutReason dont_optimize_reason() { return kNoReason; }
1060 int* ast_properties() { 1068 int* ast_properties() {
1061 static int dummy = 42; 1069 static int dummy = 42;
1062 return &dummy; 1070 return &dummy;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 return 0; 1325 return 0;
1318 } 1326 }
1319 1327
1320 static AstValueFactory* ast_value_factory() { return NULL; } 1328 static AstValueFactory* ast_value_factory() { return NULL; }
1321 1329
1322 void CheckConflictingVarDeclarations(PreParserScope scope, bool* ok) {} 1330 void CheckConflictingVarDeclarations(PreParserScope scope, bool* ok) {}
1323 1331
1324 // Temporary glue; these functions will move to ParserBase. 1332 // Temporary glue; these functions will move to ParserBase.
1325 PreParserExpression ParseV8Intrinsic(bool* ok); 1333 PreParserExpression ParseV8Intrinsic(bool* ok);
1326 PreParserExpression ParseFunctionLiteral( 1334 PreParserExpression ParseFunctionLiteral(
1327 PreParserIdentifier name, 1335 PreParserIdentifier name, Scanner::Location function_name_location,
1328 Scanner::Location function_name_location,
1329 bool name_is_strict_reserved, 1336 bool name_is_strict_reserved,
1330 bool is_generator, 1337 FunctionLiteral::IsGeneratorFlag is_generator,
1331 int function_token_position, 1338 FunctionLiteral::IsArrowFlag is_arrow,
1332 FunctionLiteral::FunctionType type, 1339 FunctionLiteral::IsConciseMethodFlag is_concise_method,
1333 FunctionLiteral::ArityRestriction arity_restriction, 1340 int function_token_position, FunctionLiteral::FunctionType type,
1334 bool* ok); 1341 FunctionLiteral::ArityRestriction arity_restriction, bool* ok);
1335 1342
1336 private: 1343 private:
1337 PreParser* pre_parser_; 1344 PreParser* pre_parser_;
1338 }; 1345 };
1339 1346
1340 1347
1341 // Preparsing checks a JavaScript program and emits preparse-data that helps 1348 // Preparsing checks a JavaScript program and emits preparse-data that helps
1342 // a later parsing to be faster. 1349 // a later parsing to be faster.
1343 // See preparse-data-format.h for the data format. 1350 // See preparse-data-format.h for the data format.
1344 1351
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 1462
1456 V8_INLINE void SkipLazyFunctionBody(PreParserIdentifier function_name, 1463 V8_INLINE void SkipLazyFunctionBody(PreParserIdentifier function_name,
1457 int* materialized_literal_count, 1464 int* materialized_literal_count,
1458 int* expected_property_count, bool* ok); 1465 int* expected_property_count, bool* ok);
1459 V8_INLINE PreParserStatementList 1466 V8_INLINE PreParserStatementList
1460 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, 1467 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos,
1461 Variable* fvar, Token::Value fvar_init_op, 1468 Variable* fvar, Token::Value fvar_init_op,
1462 bool is_generator, bool* ok); 1469 bool is_generator, bool* ok);
1463 1470
1464 Expression ParseFunctionLiteral( 1471 Expression ParseFunctionLiteral(
1465 Identifier name, 1472 Identifier name, Scanner::Location function_name_location,
1466 Scanner::Location function_name_location,
1467 bool name_is_strict_reserved, 1473 bool name_is_strict_reserved,
1468 bool is_generator, 1474 FunctionLiteral::IsGeneratorFlag is_generator,
1469 int function_token_pos, 1475 FunctionLiteral::IsArrowFlag is_arrow,
1470 FunctionLiteral::FunctionType function_type, 1476 FunctionLiteral::IsConciseMethodFlag is_concise_method,
1471 FunctionLiteral::ArityRestriction arity_restriction, 1477 int function_token_pos, FunctionLiteral::FunctionType function_type,
1472 bool* ok); 1478 FunctionLiteral::ArityRestriction arity_restriction, bool* ok);
1473 void ParseLazyFunctionLiteralBody(bool* ok); 1479 void ParseLazyFunctionLiteralBody(bool* ok);
1474 1480
1475 bool CheckInOrOf(bool accept_OF); 1481 bool CheckInOrOf(bool accept_OF);
1476 }; 1482 };
1477 1483
1478 1484
1479 PreParserStatementList PreParser::ParseEagerFunctionBody( 1485 PreParserStatementList PreParser::ParseEagerFunctionBody(
1480 PreParserIdentifier function_name, int pos, Variable* fvar, 1486 PreParserIdentifier function_name, int pos, Variable* fvar,
1481 Token::Value fvar_init_op, bool is_generator, bool* ok) { 1487 Token::Value fvar_init_op, bool is_generator, bool* ok) {
1482 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); 1488 ParsingModeScope parsing_mode(this, PARSE_EAGERLY);
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 } 1854 }
1849 1855
1850 1856
1851 template <class Traits> 1857 template <class Traits>
1852 typename ParserBase<Traits>::ObjectLiteralPropertyT ParserBase< 1858 typename ParserBase<Traits>::ObjectLiteralPropertyT ParserBase<
1853 Traits>::ParsePropertyDefinition(ObjectLiteralChecker* checker, bool* ok) { 1859 Traits>::ParsePropertyDefinition(ObjectLiteralChecker* checker, bool* ok) {
1854 LiteralT key = this->EmptyLiteral(); 1860 LiteralT key = this->EmptyLiteral();
1855 Token::Value next = peek(); 1861 Token::Value next = peek();
1856 int next_pos = peek_position(); 1862 int next_pos = peek_position();
1857 1863
1858 switch (next) { 1864 switch (next) {
rossberg 2014/08/22 09:34:31 Perhaps add a TODO that if both harmony_object_lit
arv (Not doing code reviews) 2014/08/22 23:16:02 Done. I already have changes coming that changes
1859 case Token::STRING: { 1865 case Token::STRING: {
1860 Consume(Token::STRING); 1866 Consume(Token::STRING);
1861 IdentifierT string = this->GetSymbol(scanner_); 1867 IdentifierT string = this->GetSymbol(scanner_);
1862 if (fni_ != NULL) this->PushLiteralName(fni_, string); 1868 if (fni_ != NULL) this->PushLiteralName(fni_, string);
1863 uint32_t index; 1869 uint32_t index;
1864 if (this->IsArrayIndex(string, &index)) { 1870 if (this->IsArrayIndex(string, &index)) {
1865 key = factory()->NewNumberLiteral(index, next_pos); 1871 key = factory()->NewNumberLiteral(index, next_pos);
1866 break; 1872 break;
1867 } 1873 }
1868 key = factory()->NewStringLiteral(string, next_pos); 1874 key = factory()->NewStringLiteral(string, next_pos);
1869 break; 1875 break;
1870 } 1876 }
1871 case Token::NUMBER: { 1877 case Token::NUMBER: {
1872 Consume(Token::NUMBER); 1878 Consume(Token::NUMBER);
1873 key = this->ExpressionFromLiteral(Token::NUMBER, next_pos, scanner_, 1879 key = this->ExpressionFromLiteral(Token::NUMBER, next_pos, scanner_,
1874 factory()); 1880 factory());
1875 break; 1881 break;
1876 } 1882 }
1877 default: { 1883 default: {
1878 bool is_getter = false; 1884 bool is_getter = false;
1879 bool is_setter = false; 1885 bool is_setter = false;
1880 IdentifierT id = ParseIdentifierNameOrGetOrSet( 1886 IdentifierT id = ParseIdentifierNameOrGetOrSet(
1881 &is_getter, &is_setter, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1887 &is_getter, &is_setter, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1882 if (fni_ != NULL) this->PushLiteralName(fni_, id); 1888 if (fni_ != NULL) this->PushLiteralName(fni_, id);
1883 1889
1884 if ((is_getter || is_setter) && peek() != Token::COLON) { 1890 if ((is_getter || is_setter) && peek() != Token::COLON &&
1891 (!allow_harmony_object_literals_ || peek() != Token::LPAREN)) {
1885 // Special handling of getter and setter syntax: 1892 // Special handling of getter and setter syntax:
1886 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... } 1893 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... }
1887 // We have already read the "get" or "set" keyword. 1894 // We have already read the "get" or "set" keyword.
1888 IdentifierT name = this->EmptyIdentifier(); 1895 IdentifierT name = this->EmptyIdentifier();
1889 switch (peek()) { 1896 switch (peek()) {
1890 case Token::STRING: 1897 case Token::STRING:
1891 Consume(Token::STRING); 1898 Consume(Token::STRING);
1892 name = this->GetSymbol(scanner_); 1899 name = this->GetSymbol(scanner_);
1893 break; 1900 break;
1894 case Token::NUMBER: 1901 case Token::NUMBER:
1895 Consume(Token::NUMBER); 1902 Consume(Token::NUMBER);
1896 // TODO(arv): Fix issue with numeric keys. get 1.0() should be 1903 // TODO(arv): Fix issue with numeric keys. get 1.0() should be
1897 // treated as if the key was '1' 1904 // treated as if the key was '1'.
1898 // https://code.google.com/p/v8/issues/detail?id=3507 1905 // https://code.google.com/p/v8/issues/detail?id=3507
1899 name = this->GetSymbol(scanner_); 1906 name = this->GetSymbol(scanner_);
1900 break; 1907 break;
1901 default: 1908 default:
1902 name = ParseIdentifierName( 1909 name = ParseIdentifierName(
1903 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1910 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1904 } 1911 }
1905 // Validate the property. 1912 // Validate the property.
1906 PropertyKind type = is_getter ? kGetterProperty : kSetterProperty; 1913 PropertyKind type = is_getter ? kGetterProperty : kSetterProperty;
1907 checker->CheckProperty(next, type, 1914 checker->CheckProperty(next, type,
1908 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1915 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1909 typename Traits::Type::FunctionLiteral value = 1916 typename Traits::Type::FunctionLiteral value =
1910 this->ParseFunctionLiteral( 1917 this->ParseFunctionLiteral(
1911 name, scanner()->location(), 1918 name, scanner()->location(),
1912 false, // reserved words are allowed here 1919 false, // reserved words are allowed here
1913 false, // not a generator 1920 FunctionLiteral::kNotGenerator, FunctionLiteral::kNotArrow,
1914 RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, 1921 FunctionLiteral::kNotConciseMethod, RelocInfo::kNoPosition,
1922 FunctionLiteral::ANONYMOUS_EXPRESSION,
1915 is_getter ? FunctionLiteral::GETTER_ARITY 1923 is_getter ? FunctionLiteral::GETTER_ARITY
1916 : FunctionLiteral::SETTER_ARITY, 1924 : FunctionLiteral::SETTER_ARITY,
1917 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1925 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1918 return factory()->NewObjectLiteralProperty(is_getter, value, next_pos); 1926 return factory()->NewObjectLiteralProperty(is_getter, value, next_pos);
1919 } 1927 }
1920 // Failed to parse as get/set property, so it's just a normal property 1928 // Failed to parse as get/set property, so it's just a normal property
1921 // (which might be called "get" or "set" or something else). 1929 // (which might be called "get" or "set" or something else).
1922 key = factory()->NewStringLiteral(id, next_pos); 1930 key = factory()->NewStringLiteral(id, next_pos);
1923 } 1931 }
1924 } 1932 }
1925 1933
1926 // Validate the property 1934 // Validate the property
1927 checker->CheckProperty(next, kValueProperty, 1935 checker->CheckProperty(next, kValueProperty,
1928 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1936 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1929 1937
1930 Expect(Token::COLON, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1938 ExpressionT value = this->EmptyExpression();
1931 ExpressionT value = this->ParseAssignmentExpression( 1939
1932 true, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1940 if (allow_harmony_object_literals_ && peek() == Token::LPAREN) {
1941 // TODO(arv): If the FunctionBody references super we need to call
1942 // MakeMethod.
1943
1944 // TODO(arv): Fix issue with numeric keys. 1.0() should be treated as if the
1945 // key was '1'.
1946 // https://code.google.com/p/v8/issues/detail?id=3507
1947 IdentifierT name = this->GetSymbol(scanner());
1948
1949 value = this->ParseFunctionLiteral(
1950 name, scanner()->location(),
1951 false, // reserved words are allowed here
1952 FunctionLiteral::kNotGenerator, FunctionLiteral::kNotArrow,
1953 FunctionLiteral::kIsConciseMethod, RelocInfo::kNoPosition,
1954 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::NORMAL_ARITY,
1955 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1956 } else {
1957 Expect(Token::COLON, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1958 value = this->ParseAssignmentExpression(
1959 true, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1960 }
1933 1961
1934 return factory()->NewObjectLiteralProperty(key, value); 1962 return factory()->NewObjectLiteralProperty(key, value);
1935 } 1963 }
1936 1964
1937 1965
1938 template <class Traits> 1966 template <class Traits>
1939 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseObjectLiteral( 1967 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseObjectLiteral(
1940 bool* ok) { 1968 bool* ok) {
1941 // ObjectLiteral :: 1969 // ObjectLiteral ::
1942 // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}' 1970 // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}'
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
2421 bool is_strict_reserved_name = false; 2449 bool is_strict_reserved_name = false;
2422 Scanner::Location function_name_location = Scanner::Location::invalid(); 2450 Scanner::Location function_name_location = Scanner::Location::invalid();
2423 FunctionLiteral::FunctionType function_type = 2451 FunctionLiteral::FunctionType function_type =
2424 FunctionLiteral::ANONYMOUS_EXPRESSION; 2452 FunctionLiteral::ANONYMOUS_EXPRESSION;
2425 if (peek_any_identifier()) { 2453 if (peek_any_identifier()) {
2426 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name, 2454 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name,
2427 CHECK_OK); 2455 CHECK_OK);
2428 function_name_location = scanner()->location(); 2456 function_name_location = scanner()->location();
2429 function_type = FunctionLiteral::NAMED_EXPRESSION; 2457 function_type = FunctionLiteral::NAMED_EXPRESSION;
2430 } 2458 }
2431 result = this->ParseFunctionLiteral(name, 2459 result = this->ParseFunctionLiteral(
2432 function_name_location, 2460 name, function_name_location, is_strict_reserved_name,
2433 is_strict_reserved_name, 2461 is_generator ? FunctionLiteral::kIsGenerator
2434 is_generator, 2462 : FunctionLiteral::kNotGenerator,
2435 function_token_position, 2463 FunctionLiteral::kNotArrow, FunctionLiteral::kNotConciseMethod,
2436 function_type, 2464 function_token_position, function_type, FunctionLiteral::NORMAL_ARITY,
2437 FunctionLiteral::NORMAL_ARITY, 2465 CHECK_OK);
2438 CHECK_OK);
2439 } else if (peek() == Token::SUPER) { 2466 } else if (peek() == Token::SUPER) {
2440 int beg_pos = position(); 2467 int beg_pos = position();
2441 Consume(Token::SUPER); 2468 Consume(Token::SUPER);
2442 Token::Value next = peek(); 2469 Token::Value next = peek();
2443 if (next == Token::PERIOD || next == Token::LBRACK || 2470 if (next == Token::PERIOD || next == Token::LBRACK ||
2444 next == Token::LPAREN) { 2471 next == Token::LPAREN) {
2445 result = this->SuperReference(scope_, factory()); 2472 result = this->SuperReference(scope_, factory());
2446 } else { 2473 } else {
2447 ReportMessageAt(Scanner::Location(beg_pos, position()), 2474 ReportMessageAt(Scanner::Location(beg_pos, position()),
2448 "unexpected_super"); 2475 "unexpected_super");
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2589 2616
2590 ast_properties = *factory()->visitor()->ast_properties(); 2617 ast_properties = *factory()->visitor()->ast_properties();
2591 dont_optimize_reason = factory()->visitor()->dont_optimize_reason(); 2618 dont_optimize_reason = factory()->visitor()->dont_optimize_reason();
2592 } 2619 }
2593 2620
2594 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( 2621 FunctionLiteralT function_literal = factory()->NewFunctionLiteral(
2595 this->EmptyIdentifierString(), this->ast_value_factory(), scope, body, 2622 this->EmptyIdentifierString(), this->ast_value_factory(), scope, body,
2596 materialized_literal_count, expected_property_count, handler_count, 2623 materialized_literal_count, expected_property_count, handler_count,
2597 num_parameters, FunctionLiteral::kNoDuplicateParameters, 2624 num_parameters, FunctionLiteral::kNoDuplicateParameters,
2598 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, 2625 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction,
2599 FunctionLiteral::kNotParenthesized, FunctionLiteral::kArrowFunction, 2626 FunctionLiteral::kNotParenthesized, FunctionLiteral::kNotGenerator,
2600 start_pos); 2627 FunctionLiteral::kIsArrow, FunctionLiteral::kNotConciseMethod, start_pos);
2601 2628
2602 function_literal->set_function_token_position(start_pos); 2629 function_literal->set_function_token_position(start_pos);
2603 function_literal->set_ast_properties(&ast_properties); 2630 function_literal->set_ast_properties(&ast_properties);
2604 function_literal->set_dont_optimize_reason(dont_optimize_reason); 2631 function_literal->set_dont_optimize_reason(dont_optimize_reason);
2605 2632
2606 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); 2633 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal);
2607 2634
2608 return function_literal; 2635 return function_literal;
2609 } 2636 }
2610 2637
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 DCHECK(IsAccessorAccessorConflict(old_type, type)); 2688 DCHECK(IsAccessorAccessorConflict(old_type, type));
2662 // Both accessors of the same type. 2689 // Both accessors of the same type.
2663 parser()->ReportMessage("accessor_get_set"); 2690 parser()->ReportMessage("accessor_get_set");
2664 } 2691 }
2665 *ok = false; 2692 *ok = false;
2666 } 2693 }
2667 } 2694 }
2668 } } // v8::internal 2695 } } // v8::internal
2669 2696
2670 #endif // V8_PREPARSER_H 2697 #endif // V8_PREPARSER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698