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/func-name-inferrer.h" | 8 #include "src/func-name-inferrer.h" |
9 #include "src/hashmap.h" | 9 #include "src/hashmap.h" |
10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 | 1037 |
1038 // Temporary glue; these functions will move to ParserBase. | 1038 // Temporary glue; these functions will move to ParserBase. |
1039 PreParserExpression ParseV8Intrinsic(bool* ok); | 1039 PreParserExpression ParseV8Intrinsic(bool* ok); |
1040 PreParserExpression ParseFunctionLiteral( | 1040 PreParserExpression ParseFunctionLiteral( |
1041 PreParserIdentifier name, | 1041 PreParserIdentifier name, |
1042 Scanner::Location function_name_location, | 1042 Scanner::Location function_name_location, |
1043 bool name_is_strict_reserved, | 1043 bool name_is_strict_reserved, |
1044 bool is_generator, | 1044 bool is_generator, |
1045 int function_token_position, | 1045 int function_token_position, |
1046 FunctionLiteral::FunctionType type, | 1046 FunctionLiteral::FunctionType type, |
| 1047 FunctionLiteral::ArityRestriction arity_restriction, |
1047 bool* ok); | 1048 bool* ok); |
1048 | 1049 |
1049 private: | 1050 private: |
1050 PreParser* pre_parser_; | 1051 PreParser* pre_parser_; |
1051 }; | 1052 }; |
1052 | 1053 |
1053 | 1054 |
1054 // Preparsing checks a JavaScript program and emits preparse-data that helps | 1055 // Preparsing checks a JavaScript program and emits preparse-data that helps |
1055 // a later parsing to be faster. | 1056 // a later parsing to be faster. |
1056 // See preparse-data-format.h for the data format. | 1057 // See preparse-data-format.h for the data format. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 Expression ParseObjectLiteral(bool* ok); | 1167 Expression ParseObjectLiteral(bool* ok); |
1167 Expression ParseV8Intrinsic(bool* ok); | 1168 Expression ParseV8Intrinsic(bool* ok); |
1168 | 1169 |
1169 Expression ParseFunctionLiteral( | 1170 Expression ParseFunctionLiteral( |
1170 Identifier name, | 1171 Identifier name, |
1171 Scanner::Location function_name_location, | 1172 Scanner::Location function_name_location, |
1172 bool name_is_strict_reserved, | 1173 bool name_is_strict_reserved, |
1173 bool is_generator, | 1174 bool is_generator, |
1174 int function_token_pos, | 1175 int function_token_pos, |
1175 FunctionLiteral::FunctionType function_type, | 1176 FunctionLiteral::FunctionType function_type, |
| 1177 FunctionLiteral::ArityRestriction arity_restriction, |
1176 bool* ok); | 1178 bool* ok); |
1177 void ParseLazyFunctionLiteralBody(bool* ok); | 1179 void ParseLazyFunctionLiteralBody(bool* ok); |
1178 | 1180 |
1179 bool CheckInOrOf(bool accept_OF); | 1181 bool CheckInOrOf(bool accept_OF); |
1180 }; | 1182 }; |
1181 | 1183 |
1182 template<class Traits> | 1184 template<class Traits> |
1183 ParserBase<Traits>::FunctionState::FunctionState( | 1185 ParserBase<Traits>::FunctionState::FunctionState( |
1184 FunctionState** function_state_stack, | 1186 FunctionState** function_state_stack, |
1185 typename Traits::Type::Scope** scope_stack, | 1187 typename Traits::Type::Scope** scope_stack, |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 // Validate the property. | 1547 // Validate the property. |
1546 PropertyKind type = is_getter ? kGetterProperty : kSetterProperty; | 1548 PropertyKind type = is_getter ? kGetterProperty : kSetterProperty; |
1547 checker.CheckProperty(next, type, CHECK_OK); | 1549 checker.CheckProperty(next, type, CHECK_OK); |
1548 IdentifierT name = this->GetSymbol(scanner_); | 1550 IdentifierT name = this->GetSymbol(scanner_); |
1549 typename Traits::Type::FunctionLiteral value = | 1551 typename Traits::Type::FunctionLiteral value = |
1550 this->ParseFunctionLiteral( | 1552 this->ParseFunctionLiteral( |
1551 name, scanner()->location(), | 1553 name, scanner()->location(), |
1552 false, // reserved words are allowed here | 1554 false, // reserved words are allowed here |
1553 false, // not a generator | 1555 false, // not a generator |
1554 RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, | 1556 RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, |
| 1557 is_getter ? FunctionLiteral::GETTER_ARITY |
| 1558 : FunctionLiteral::SETTER_ARITY, |
1555 CHECK_OK); | 1559 CHECK_OK); |
1556 // Allow any number of parameters for compatibilty with JSC. | |
1557 // Specification only allows zero parameters for get and one for set. | |
1558 typename Traits::Type::ObjectLiteralProperty property = | 1560 typename Traits::Type::ObjectLiteralProperty property = |
1559 factory()->NewObjectLiteralProperty(is_getter, value, next_pos); | 1561 factory()->NewObjectLiteralProperty(is_getter, value, next_pos); |
1560 if (this->IsBoilerplateProperty(property)) { | 1562 if (this->IsBoilerplateProperty(property)) { |
1561 number_of_boilerplate_properties++; | 1563 number_of_boilerplate_properties++; |
1562 } | 1564 } |
1563 properties->Add(property, zone()); | 1565 properties->Add(property, zone()); |
1564 if (peek() != Token::RBRACE) { | 1566 if (peek() != Token::RBRACE) { |
1565 // Need {} because of the CHECK_OK macro. | 1567 // Need {} because of the CHECK_OK macro. |
1566 Expect(Token::COMMA, CHECK_OK); | 1568 Expect(Token::COMMA, CHECK_OK); |
1567 } | 1569 } |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 CHECK_OK); | 2051 CHECK_OK); |
2050 function_name_location = scanner()->location(); | 2052 function_name_location = scanner()->location(); |
2051 function_type = FunctionLiteral::NAMED_EXPRESSION; | 2053 function_type = FunctionLiteral::NAMED_EXPRESSION; |
2052 } | 2054 } |
2053 result = this->ParseFunctionLiteral(name, | 2055 result = this->ParseFunctionLiteral(name, |
2054 function_name_location, | 2056 function_name_location, |
2055 is_strict_reserved_name, | 2057 is_strict_reserved_name, |
2056 is_generator, | 2058 is_generator, |
2057 function_token_position, | 2059 function_token_position, |
2058 function_type, | 2060 function_type, |
| 2061 FunctionLiteral::NORMAL_ARITY, |
2059 CHECK_OK); | 2062 CHECK_OK); |
2060 } else { | 2063 } else { |
2061 result = ParsePrimaryExpression(CHECK_OK); | 2064 result = ParsePrimaryExpression(CHECK_OK); |
2062 } | 2065 } |
2063 | 2066 |
2064 result = ParseMemberExpressionContinuation(result, CHECK_OK); | 2067 result = ParseMemberExpressionContinuation(result, CHECK_OK); |
2065 return result; | 2068 return result; |
2066 } | 2069 } |
2067 | 2070 |
2068 | 2071 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2161 parser()->ReportMessage("accessor_get_set"); | 2164 parser()->ReportMessage("accessor_get_set"); |
2162 } | 2165 } |
2163 *ok = false; | 2166 *ok = false; |
2164 } | 2167 } |
2165 } | 2168 } |
2166 | 2169 |
2167 | 2170 |
2168 } } // v8::internal | 2171 } } // v8::internal |
2169 | 2172 |
2170 #endif // V8_PREPARSER_H | 2173 #endif // V8_PREPARSER_H |
OLD | NEW |