| 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 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
| 10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 | 743 |
| 744 Expression* ParserTraits::ParseV8Intrinsic(bool* ok) { | 744 Expression* ParserTraits::ParseV8Intrinsic(bool* ok) { |
| 745 return parser_->ParseV8Intrinsic(ok); | 745 return parser_->ParseV8Intrinsic(ok); |
| 746 } | 746 } |
| 747 | 747 |
| 748 | 748 |
| 749 FunctionLiteral* ParserTraits::ParseFunctionLiteral( | 749 FunctionLiteral* ParserTraits::ParseFunctionLiteral( |
| 750 const AstRawString* name, Scanner::Location function_name_location, | 750 const AstRawString* name, Scanner::Location function_name_location, |
| 751 FunctionNameValidity function_name_validity, FunctionKind kind, | 751 FunctionNameValidity function_name_validity, FunctionKind kind, |
| 752 int function_token_position, FunctionLiteral::FunctionType type, | 752 int function_token_position, FunctionLiteral::FunctionType type, |
| 753 LanguageMode language_mode, bool* ok) { | 753 LanguageMode language_mode, typesystem::TypeFlags type_flags, bool* ok) { |
| 754 return parser_->ParseFunctionLiteral( | 754 return parser_->ParseFunctionLiteral( |
| 755 name, function_name_location, function_name_validity, kind, | 755 name, function_name_location, function_name_validity, kind, |
| 756 function_token_position, type, language_mode, ok); | 756 function_token_position, type, language_mode, type_flags, ok); |
| 757 } | 757 } |
| 758 | 758 |
| 759 | 759 |
| 760 ClassLiteral* ParserTraits::ParseClassLiteral( | 760 ClassLiteral* ParserTraits::ParseClassLiteral( |
| 761 const AstRawString* name, Scanner::Location class_name_location, | 761 const AstRawString* name, Scanner::Location class_name_location, |
| 762 bool name_is_strict_reserved, int pos, bool* ok) { | 762 bool name_is_strict_reserved, int pos, bool* ok) { |
| 763 return parser_->ParseClassLiteral(name, class_name_location, | 763 return parser_->ParseClassLiteral(name, class_name_location, |
| 764 name_is_strict_reserved, pos, ok); | 764 name_is_strict_reserved, pos, ok); |
| 765 } | 765 } |
| 766 | 766 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 ExpressionClassifier formals_classifier(this); | 1087 ExpressionClassifier formals_classifier(this); |
| 1088 ParserFormalParameters formals(scope); | 1088 ParserFormalParameters formals(scope); |
| 1089 Checkpoint checkpoint(this); | 1089 Checkpoint checkpoint(this); |
| 1090 { | 1090 { |
| 1091 // Parsing patterns as variable reference expression creates | 1091 // Parsing patterns as variable reference expression creates |
| 1092 // NewUnresolved references in current scope. Entrer arrow function | 1092 // NewUnresolved references in current scope. Entrer arrow function |
| 1093 // scope for formal parameter parsing. | 1093 // scope for formal parameter parsing. |
| 1094 BlockState block_state(&scope_, scope); | 1094 BlockState block_state(&scope_, scope); |
| 1095 if (Check(Token::LPAREN)) { | 1095 if (Check(Token::LPAREN)) { |
| 1096 // '(' StrictFormalParameters ')' | 1096 // '(' StrictFormalParameters ')' |
| 1097 ParseFormalParameterList(&formals, &formals_classifier, &ok); | 1097 ParseFormalParameterList(&formals, true, &formals_classifier, &ok); |
| 1098 if (ok) ok = Check(Token::RPAREN); | 1098 if (ok) ok = Check(Token::RPAREN); |
| 1099 } else { | 1099 } else { |
| 1100 // BindingIdentifier | 1100 // BindingIdentifier |
| 1101 ParseFormalParameter(&formals, &formals_classifier, &ok); | 1101 ParseFormalParameter(&formals, false, &formals_classifier, &ok); |
| 1102 if (ok) { | 1102 if (ok) { |
| 1103 DeclareFormalParameter(formals.scope, formals.at(0), | 1103 DeclareFormalParameter(formals.scope, formals.at(0), |
| 1104 &formals_classifier); | 1104 &formals_classifier); |
| 1105 } | 1105 } |
| 1106 } | 1106 } |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 if (ok) { | 1109 if (ok) { |
| 1110 checkpoint.Restore(&formals.materialized_literals_count); | 1110 checkpoint.Restore(&formals.materialized_literals_count); |
| 1111 // Pass `accept_IN=true` to ParseArrowFunctionLiteral --- This should | 1111 // Pass `accept_IN=true` to ParseArrowFunctionLiteral --- This should |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1128 ok = false; | 1128 ok = false; |
| 1129 } | 1129 } |
| 1130 } | 1130 } |
| 1131 } | 1131 } |
| 1132 } else if (shared_info->is_default_constructor()) { | 1132 } else if (shared_info->is_default_constructor()) { |
| 1133 result = DefaultConstructor( | 1133 result = DefaultConstructor( |
| 1134 raw_name, IsSubclassConstructor(shared_info->kind()), scope, | 1134 raw_name, IsSubclassConstructor(shared_info->kind()), scope, |
| 1135 shared_info->start_position(), shared_info->end_position(), | 1135 shared_info->start_position(), shared_info->end_position(), |
| 1136 shared_info->language_mode()); | 1136 shared_info->language_mode()); |
| 1137 } else { | 1137 } else { |
| 1138 result = ParseFunctionLiteral(raw_name, Scanner::Location::invalid(), | 1138 result = ParseFunctionLiteral( |
| 1139 kSkipFunctionNameCheck, shared_info->kind(), | 1139 raw_name, Scanner::Location::invalid(), kSkipFunctionNameCheck, |
| 1140 RelocInfo::kNoPosition, function_type, | 1140 shared_info->kind(), RelocInfo::kNoPosition, function_type, |
| 1141 shared_info->language_mode(), &ok); | 1141 shared_info->language_mode(), typesystem::kNormalTypes, &ok); |
| 1142 } | 1142 } |
| 1143 // Make sure the results agree. | 1143 // Make sure the results agree. |
| 1144 DCHECK(ok == (result != NULL)); | 1144 DCHECK(ok == (result != NULL)); |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 // Make sure the target stack is empty. | 1147 // Make sure the target stack is empty. |
| 1148 DCHECK(target_stack_ == NULL); | 1148 DCHECK(target_stack_ == NULL); |
| 1149 | 1149 |
| 1150 if (result != NULL) { | 1150 if (result != NULL) { |
| 1151 Handle<String> inferred_name(shared_info->inferred_name()); | 1151 Handle<String> inferred_name(shared_info->inferred_name()); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 | 1598 |
| 1599 const AstRawString* default_string = ast_value_factory()->default_string(); | 1599 const AstRawString* default_string = ast_value_factory()->default_string(); |
| 1600 ZoneList<const AstRawString*> names(1, zone()); | 1600 ZoneList<const AstRawString*> names(1, zone()); |
| 1601 Statement* result = nullptr; | 1601 Statement* result = nullptr; |
| 1602 Expression* default_export = nullptr; | 1602 Expression* default_export = nullptr; |
| 1603 switch (peek()) { | 1603 switch (peek()) { |
| 1604 case Token::FUNCTION: { | 1604 case Token::FUNCTION: { |
| 1605 Consume(Token::FUNCTION); | 1605 Consume(Token::FUNCTION); |
| 1606 int pos = position(); | 1606 int pos = position(); |
| 1607 bool is_generator = Check(Token::MUL); | 1607 bool is_generator = Check(Token::MUL); |
| 1608 if (peek() == Token::LPAREN) { | 1608 if (peek() == Token::LPAREN || (scope_->typed() && Check(Token::LT))) { |
| 1609 // FunctionDeclaration[+Default] :: | 1609 // FunctionDeclaration[+Default] :: |
| 1610 // 'function' '(' FormalParameters ')' '{' FunctionBody '}' | 1610 // 'function' '(' FormalParameters ')' '{' FunctionBody '}' |
| 1611 // | 1611 // |
| 1612 // GeneratorDeclaration[+Default] :: | 1612 // GeneratorDeclaration[+Default] :: |
| 1613 // 'function' '*' '(' FormalParameters ')' '{' FunctionBody '}' | 1613 // 'function' '*' '(' FormalParameters ')' '{' FunctionBody '}' |
| 1614 default_export = ParseFunctionLiteral( | 1614 default_export = ParseFunctionLiteral( |
| 1615 default_string, Scanner::Location::invalid(), | 1615 default_string, Scanner::Location::invalid(), |
| 1616 kSkipFunctionNameCheck, | 1616 kSkipFunctionNameCheck, |
| 1617 is_generator ? FunctionKind::kGeneratorFunction | 1617 is_generator ? FunctionKind::kGeneratorFunction |
| 1618 : FunctionKind::kNormalFunction, | 1618 : FunctionKind::kNormalFunction, |
| 1619 pos, FunctionLiteral::kDeclaration, language_mode(), CHECK_OK); | 1619 pos, FunctionLiteral::kDeclaration, language_mode(), |
| 1620 typesystem::kAllowSignature, CHECK_OK); |
| 1620 result = factory()->NewEmptyStatement(RelocInfo::kNoPosition); | 1621 result = factory()->NewEmptyStatement(RelocInfo::kNoPosition); |
| 1621 } else { | 1622 } else { |
| 1622 result = ParseFunctionDeclaration(pos, is_generator, &names, CHECK_OK); | 1623 result = ParseFunctionDeclaration(pos, is_generator, &names, CHECK_OK); |
| 1623 } | 1624 } |
| 1624 break; | 1625 break; |
| 1625 } | 1626 } |
| 1626 | 1627 |
| 1627 case Token::CLASS: | 1628 case Token::CLASS: |
| 1628 Consume(Token::CLASS); | 1629 Consume(Token::CLASS); |
| 1629 if (peek() == Token::EXTENDS || peek() == Token::LBRACE) { | 1630 if (peek() == Token::EXTENDS || peek() == Token::LBRACE) { |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2160 // GeneratorDeclaration :: | 2161 // GeneratorDeclaration :: |
| 2161 // 'function' '*' Identifier '(' FormalParameters ')' '{' FunctionBody '}' | 2162 // 'function' '*' Identifier '(' FormalParameters ')' '{' FunctionBody '}' |
| 2162 // | 2163 // |
| 2163 // 'function' and '*' (if present) have been consumed by the caller. | 2164 // 'function' and '*' (if present) have been consumed by the caller. |
| 2164 bool is_strict_reserved = false; | 2165 bool is_strict_reserved = false; |
| 2165 const AstRawString* name = ParseIdentifierOrStrictReservedWord( | 2166 const AstRawString* name = ParseIdentifierOrStrictReservedWord( |
| 2166 &is_strict_reserved, CHECK_OK); | 2167 &is_strict_reserved, CHECK_OK); |
| 2167 | 2168 |
| 2168 FuncNameInferrer::State fni_state(fni_); | 2169 FuncNameInferrer::State fni_state(fni_); |
| 2169 if (fni_ != NULL) fni_->PushEnclosingName(name); | 2170 if (fni_ != NULL) fni_->PushEnclosingName(name); |
| 2170 FunctionLiteral* fun = ParseFunctionLiteral( | 2171 FunctionLiteral* fun = |
| 2171 name, scanner()->location(), | 2172 ParseFunctionLiteral(name, scanner()->location(), |
| 2172 is_strict_reserved ? kFunctionNameIsStrictReserved | 2173 is_strict_reserved ? kFunctionNameIsStrictReserved |
| 2173 : kFunctionNameValidityUnknown, | 2174 : kFunctionNameValidityUnknown, |
| 2174 is_generator ? FunctionKind::kGeneratorFunction | 2175 is_generator ? FunctionKind::kGeneratorFunction |
| 2175 : FunctionKind::kNormalFunction, | 2176 : FunctionKind::kNormalFunction, |
| 2176 pos, FunctionLiteral::kDeclaration, language_mode(), CHECK_OK); | 2177 pos, FunctionLiteral::kDeclaration, language_mode(), |
| 2178 typesystem::kAllowSignature, CHECK_OK); |
| 2179 // Return no function declaration if just the signature was given. |
| 2180 EmptyStatement* empty = factory()->NewEmptyStatement(RelocInfo::kNoPosition); |
| 2181 if (fun == nullptr) return empty; |
| 2177 | 2182 |
| 2178 // Even if we're not at the top-level of the global or a function | 2183 // Even if we're not at the top-level of the global or a function |
| 2179 // scope, we treat it as such and introduce the function with its | 2184 // scope, we treat it as such and introduce the function with its |
| 2180 // initial value upon entering the corresponding scope. | 2185 // initial value upon entering the corresponding scope. |
| 2181 // In ES6, a function behaves as a lexical binding, except in | 2186 // In ES6, a function behaves as a lexical binding, except in |
| 2182 // a script scope, or the initial scope of eval or another function. | 2187 // a script scope, or the initial scope of eval or another function. |
| 2183 VariableMode mode = | 2188 VariableMode mode = |
| 2184 (is_strict(language_mode()) || allow_harmony_sloppy_function()) && | 2189 (is_strict(language_mode()) || allow_harmony_sloppy_function()) && |
| 2185 !scope_->is_declaration_scope() | 2190 !scope_->is_declaration_scope() |
| 2186 ? LET | 2191 ? LET |
| 2187 : VAR; | 2192 : VAR; |
| 2188 VariableProxy* proxy = NewUnresolved(name, mode); | 2193 VariableProxy* proxy = NewUnresolved(name, mode); |
| 2189 Declaration* declaration = | 2194 Declaration* declaration = |
| 2190 factory()->NewFunctionDeclaration(proxy, mode, fun, scope_, pos); | 2195 factory()->NewFunctionDeclaration(proxy, mode, fun, scope_, pos); |
| 2191 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); | 2196 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); |
| 2192 if (names) names->Add(name, zone()); | 2197 if (names) names->Add(name, zone()); |
| 2193 EmptyStatement* empty = factory()->NewEmptyStatement(RelocInfo::kNoPosition); | |
| 2194 if (is_sloppy(language_mode()) && allow_harmony_sloppy_function() && | 2198 if (is_sloppy(language_mode()) && allow_harmony_sloppy_function() && |
| 2195 !scope_->is_declaration_scope()) { | 2199 !scope_->is_declaration_scope()) { |
| 2196 SloppyBlockFunctionStatement* delegate = | 2200 SloppyBlockFunctionStatement* delegate = |
| 2197 factory()->NewSloppyBlockFunctionStatement(empty, scope_); | 2201 factory()->NewSloppyBlockFunctionStatement(empty, scope_); |
| 2198 scope_->DeclarationScope()->sloppy_block_function_map()->Declare(name, | 2202 scope_->DeclarationScope()->sloppy_block_function_map()->Declare(name, |
| 2199 delegate); | 2203 delegate); |
| 2200 return delegate; | 2204 return delegate; |
| 2201 } | 2205 } |
| 2202 return empty; | 2206 return empty; |
| 2203 } | 2207 } |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2390 int decl_pos = peek_position(); | 2394 int decl_pos = peek_position(); |
| 2391 { | 2395 { |
| 2392 ExpressionClassifier pattern_classifier(this); | 2396 ExpressionClassifier pattern_classifier(this); |
| 2393 pattern = ParsePrimaryExpression(&pattern_classifier, CHECK_OK); | 2397 pattern = ParsePrimaryExpression(&pattern_classifier, CHECK_OK); |
| 2394 ValidateBindingPattern(&pattern_classifier, CHECK_OK); | 2398 ValidateBindingPattern(&pattern_classifier, CHECK_OK); |
| 2395 if (IsLexicalVariableMode(parsing_result->descriptor.mode)) { | 2399 if (IsLexicalVariableMode(parsing_result->descriptor.mode)) { |
| 2396 ValidateLetPattern(&pattern_classifier, CHECK_OK); | 2400 ValidateLetPattern(&pattern_classifier, CHECK_OK); |
| 2397 } | 2401 } |
| 2398 } | 2402 } |
| 2399 | 2403 |
| 2400 // Optional type annotation. | 2404 // Parse optional type annotation. |
| 2401 if (scope_->typed() && Check(Token::COLON)) { | 2405 typename TypeSystem::Type type = this->EmptyType(); |
| 2402 typename TypeSystem::Type type = ParseValidType(CHECK_OK); | 2406 if (scope_->typed() && Check(Token::COLON)) { // Braces required here. |
| 2403 USE(type); | 2407 type = ParseValidType(CHECK_OK); |
| 2404 } | 2408 } |
| 2409 USE(type); // TODO(nikolaos): really use it! |
| 2405 | 2410 |
| 2406 Scanner::Location variable_loc = scanner()->location(); | 2411 Scanner::Location variable_loc = scanner()->location(); |
| 2407 const AstRawString* single_name = | 2412 const AstRawString* single_name = |
| 2408 pattern->IsVariableProxy() ? pattern->AsVariableProxy()->raw_name() | 2413 pattern->IsVariableProxy() ? pattern->AsVariableProxy()->raw_name() |
| 2409 : nullptr; | 2414 : nullptr; |
| 2410 if (single_name != nullptr) { | 2415 if (single_name != nullptr) { |
| 2411 if (fni_ != NULL) fni_->PushVariableName(single_name); | 2416 if (fni_ != NULL) fni_->PushVariableName(single_name); |
| 2412 } | 2417 } |
| 2413 | 2418 |
| 2414 Expression* value = NULL; | 2419 Expression* value = NULL; |
| (...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4087 if (p.pattern != nullptr) reindexer.Reindex(p.pattern); | 4092 if (p.pattern != nullptr) reindexer.Reindex(p.pattern); |
| 4088 if (p.initializer != nullptr) reindexer.Reindex(p.initializer); | 4093 if (p.initializer != nullptr) reindexer.Reindex(p.initializer); |
| 4089 } | 4094 } |
| 4090 | 4095 |
| 4091 DCHECK(reindexer.count() <= | 4096 DCHECK(reindexer.count() <= |
| 4092 parser_->function_state_->materialized_literal_count()); | 4097 parser_->function_state_->materialized_literal_count()); |
| 4093 } | 4098 } |
| 4094 } | 4099 } |
| 4095 | 4100 |
| 4096 | 4101 |
| 4102 // This function may return a nullptr with *ok==true in typed mode, |
| 4103 // if (type_flags & kAllowSignature) and a function signature is parsed. |
| 4097 FunctionLiteral* Parser::ParseFunctionLiteral( | 4104 FunctionLiteral* Parser::ParseFunctionLiteral( |
| 4098 const AstRawString* function_name, Scanner::Location function_name_location, | 4105 const AstRawString* function_name, Scanner::Location function_name_location, |
| 4099 FunctionNameValidity function_name_validity, FunctionKind kind, | 4106 FunctionNameValidity function_name_validity, FunctionKind kind, |
| 4100 int function_token_pos, FunctionLiteral::FunctionType function_type, | 4107 int function_token_pos, FunctionLiteral::FunctionType function_type, |
| 4101 LanguageMode language_mode, bool* ok) { | 4108 LanguageMode language_mode, typesystem::TypeFlags type_flags, bool* ok) { |
| 4102 // Function :: | 4109 // Function :: |
| 4103 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 4110 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
| 4104 // | 4111 // |
| 4105 // Getter :: | 4112 // Getter :: |
| 4106 // '(' ')' '{' FunctionBody '}' | 4113 // '(' ')' '{' FunctionBody '}' |
| 4107 // | 4114 // |
| 4108 // Setter :: | 4115 // Setter :: |
| 4109 // '(' PropertySetParameterList ')' '{' FunctionBody '}' | 4116 // '(' PropertySetParameterList ')' '{' FunctionBody '}' |
| 4110 | 4117 |
| 4111 int pos = function_token_pos == RelocInfo::kNoPosition | 4118 int pos = function_token_pos == RelocInfo::kNoPosition |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4186 scope_->ForceContextAllocation(); | 4193 scope_->ForceContextAllocation(); |
| 4187 | 4194 |
| 4188 // Calling a generator returns a generator object. That object is stored | 4195 // Calling a generator returns a generator object. That object is stored |
| 4189 // in a temporary variable, a definition that is used by "yield" | 4196 // in a temporary variable, a definition that is used by "yield" |
| 4190 // expressions. This also marks the FunctionState as a generator. | 4197 // expressions. This also marks the FunctionState as a generator. |
| 4191 Variable* temp = scope_->NewTemporary( | 4198 Variable* temp = scope_->NewTemporary( |
| 4192 ast_value_factory()->dot_generator_object_string()); | 4199 ast_value_factory()->dot_generator_object_string()); |
| 4193 function_state.set_generator_object_variable(temp); | 4200 function_state.set_generator_object_variable(temp); |
| 4194 } | 4201 } |
| 4195 | 4202 |
| 4203 // Parse optional type parameters. |
| 4204 typename TypeSystem::TypeParameters type_parameters = |
| 4205 this->NullTypeParameters(); |
| 4206 if (scope_->typed() && |
| 4207 !(type_flags & typesystem::kDisallowTypeParameters) && |
| 4208 peek() == Token::LT) { // Braces required here. |
| 4209 type_parameters = ParseTypeParameters(CHECK_OK); |
| 4210 } |
| 4211 USE(type_parameters); // TODO(nikolaos): really use them! |
| 4212 |
| 4196 Expect(Token::LPAREN, CHECK_OK); | 4213 Expect(Token::LPAREN, CHECK_OK); |
| 4197 int start_position = scanner()->location().beg_pos; | 4214 int start_position = scanner()->location().beg_pos; |
| 4198 scope_->set_start_position(start_position); | 4215 scope_->set_start_position(start_position); |
| 4199 ParserFormalParameters formals(scope); | 4216 ParserFormalParameters formals(scope); |
| 4200 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); | 4217 ParseFormalParameterList(&formals, kind != FunctionKind::kSetterFunction, |
| 4218 &formals_classifier, CHECK_OK); |
| 4201 arity = formals.Arity(); | 4219 arity = formals.Arity(); |
| 4202 Expect(Token::RPAREN, CHECK_OK); | 4220 Expect(Token::RPAREN, CHECK_OK); |
| 4203 int formals_end_position = scanner()->location().end_pos; | 4221 int formals_end_position = scanner()->location().end_pos; |
| 4204 | 4222 |
| 4205 CheckArityRestrictions(arity, kind, formals.has_rest, start_position, | 4223 CheckArityRestrictions(arity, kind, formals.has_rest, start_position, |
| 4206 formals_end_position, CHECK_OK); | 4224 formals_end_position, CHECK_OK); |
| 4225 |
| 4226 // Parse optional type annotation. |
| 4227 typename TypeSystem::Type result_type = this->EmptyType(); |
| 4228 if (scope_->typed() && |
| 4229 !(type_flags & typesystem::kDisallowTypeAnnotation) && |
| 4230 Check(Token::COLON)) { // Braces required here. |
| 4231 result_type = ParseValidType(CHECK_OK); |
| 4232 } |
| 4233 USE(result_type); // TODO(nikolaos): really use it! |
| 4234 |
| 4235 // Allow for a function signature (i.e., a literal without body). |
| 4236 // In that case, return a nullptr instead of a function literal. |
| 4237 if (peek() != Token::LBRACE && scope_->typed() && |
| 4238 (type_flags & typesystem::kAllowSignature)) { |
| 4239 ExpectSemicolon(CHECK_OK); |
| 4240 return nullptr; |
| 4241 } |
| 4242 |
| 4207 Expect(Token::LBRACE, CHECK_OK); | 4243 Expect(Token::LBRACE, CHECK_OK); |
| 4208 | 4244 |
| 4209 // Don't include the rest parameter into the function's formal parameter | 4245 // Don't include the rest parameter into the function's formal parameter |
| 4210 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count, | 4246 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count, |
| 4211 // which says whether we need to create an arguments adaptor frame). | 4247 // which says whether we need to create an arguments adaptor frame). |
| 4212 if (formals.has_rest) arity--; | 4248 if (formals.has_rest) arity--; |
| 4213 | 4249 |
| 4214 // Determine if the function can be parsed lazily. Lazy parsing is different | 4250 // Determine if the function can be parsed lazily. Lazy parsing is different |
| 4215 // from lazy compilation; we need to parse more eagerly than we compile. | 4251 // from lazy compilation; we need to parse more eagerly than we compile. |
| 4216 | 4252 |
| (...skipping 2730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6947 try_block, target); | 6983 try_block, target); |
| 6948 final_loop = target; | 6984 final_loop = target; |
| 6949 } | 6985 } |
| 6950 | 6986 |
| 6951 return final_loop; | 6987 return final_loop; |
| 6952 } | 6988 } |
| 6953 | 6989 |
| 6954 | 6990 |
| 6955 } // namespace internal | 6991 } // namespace internal |
| 6956 } // namespace v8 | 6992 } // namespace v8 |
| OLD | NEW |