| 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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 | 721 |
| 722 Expression* ParserTraits::ParseV8Intrinsic(bool* ok) { | 722 Expression* ParserTraits::ParseV8Intrinsic(bool* ok) { |
| 723 return parser_->ParseV8Intrinsic(ok); | 723 return parser_->ParseV8Intrinsic(ok); |
| 724 } | 724 } |
| 725 | 725 |
| 726 | 726 |
| 727 FunctionLiteral* ParserTraits::ParseFunctionLiteral( | 727 FunctionLiteral* ParserTraits::ParseFunctionLiteral( |
| 728 const AstRawString* name, Scanner::Location function_name_location, | 728 const AstRawString* name, Scanner::Location function_name_location, |
| 729 FunctionNameValidity function_name_validity, FunctionKind kind, | 729 FunctionNameValidity function_name_validity, FunctionKind kind, |
| 730 int function_token_position, FunctionLiteral::FunctionType type, | 730 int function_token_position, FunctionLiteral::FunctionType type, |
| 731 FunctionLiteral::ArityRestriction arity_restriction, | |
| 732 LanguageMode language_mode, bool* ok) { | 731 LanguageMode language_mode, bool* ok) { |
| 733 return parser_->ParseFunctionLiteral( | 732 return parser_->ParseFunctionLiteral( |
| 734 name, function_name_location, function_name_validity, kind, | 733 name, function_name_location, function_name_validity, kind, |
| 735 function_token_position, type, arity_restriction, language_mode, ok); | 734 function_token_position, type, language_mode, ok); |
| 736 } | 735 } |
| 737 | 736 |
| 738 | 737 |
| 739 ClassLiteral* ParserTraits::ParseClassLiteral( | 738 ClassLiteral* ParserTraits::ParseClassLiteral( |
| 740 const AstRawString* name, Scanner::Location class_name_location, | 739 const AstRawString* name, Scanner::Location class_name_location, |
| 741 bool name_is_strict_reserved, int pos, bool* ok) { | 740 bool name_is_strict_reserved, int pos, bool* ok) { |
| 742 return parser_->ParseClassLiteral(name, class_name_location, | 741 return parser_->ParseClassLiteral(name, class_name_location, |
| 743 name_is_strict_reserved, pos, ok); | 742 name_is_strict_reserved, pos, ok); |
| 744 } | 743 } |
| 745 | 744 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 !body->at(0)->IsExpressionStatement() || | 936 !body->at(0)->IsExpressionStatement() || |
| 938 !body->at(0)->AsExpressionStatement()-> | 937 !body->at(0)->AsExpressionStatement()-> |
| 939 expression()->IsFunctionLiteral()) { | 938 expression()->IsFunctionLiteral()) { |
| 940 ReportMessage(MessageTemplate::kSingleFunctionLiteral); | 939 ReportMessage(MessageTemplate::kSingleFunctionLiteral); |
| 941 ok = false; | 940 ok = false; |
| 942 } | 941 } |
| 943 } | 942 } |
| 944 | 943 |
| 945 if (ok) { | 944 if (ok) { |
| 946 ParserTraits::RewriteDestructuringAssignments(); | 945 ParserTraits::RewriteDestructuringAssignments(); |
| 947 result = factory()->NewFunctionLiteral( | 946 result = factory()->NewScriptOrEvalFunctionLiteral( |
| 948 ast_value_factory()->empty_string(), scope_, body, | 947 scope_, body, function_state.materialized_literal_count(), |
| 949 function_state.materialized_literal_count(), | 948 function_state.expected_property_count()); |
| 950 function_state.expected_property_count(), 0, | |
| 951 FunctionLiteral::kNoDuplicateParameters, | |
| 952 FunctionLiteral::kGlobalOrEval, FunctionLiteral::kShouldLazyCompile, | |
| 953 FunctionKind::kNormalFunction, 0); | |
| 954 } | 949 } |
| 955 } | 950 } |
| 956 | 951 |
| 957 // Make sure the target stack is empty. | 952 // Make sure the target stack is empty. |
| 958 DCHECK(target_stack_ == NULL); | 953 DCHECK(target_stack_ == NULL); |
| 959 | 954 |
| 960 return result; | 955 return result; |
| 961 } | 956 } |
| 962 | 957 |
| 963 | 958 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 993 | 988 |
| 994 if (FLAG_trace_parse && result != NULL) { | 989 if (FLAG_trace_parse && result != NULL) { |
| 995 double ms = timer.Elapsed().InMillisecondsF(); | 990 double ms = timer.Elapsed().InMillisecondsF(); |
| 996 base::SmartArrayPointer<char> name_chars = | 991 base::SmartArrayPointer<char> name_chars = |
| 997 result->debug_name()->ToCString(); | 992 result->debug_name()->ToCString(); |
| 998 PrintF("[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms); | 993 PrintF("[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms); |
| 999 } | 994 } |
| 1000 return result; | 995 return result; |
| 1001 } | 996 } |
| 1002 | 997 |
| 998 static FunctionLiteral::FunctionType ComputeFunctionType( |
| 999 Handle<SharedFunctionInfo> shared_info) { |
| 1000 if (shared_info->is_declaration()) { |
| 1001 return FunctionLiteral::kDeclaration; |
| 1002 } else if (shared_info->is_named_expression()) { |
| 1003 return FunctionLiteral::kNamedExpression; |
| 1004 } else if (IsConciseMethod(shared_info->kind()) || |
| 1005 IsAccessorFunction(shared_info->kind())) { |
| 1006 return FunctionLiteral::kAccessorOrMethod; |
| 1007 } |
| 1008 return FunctionLiteral::kAnonymousExpression; |
| 1009 } |
| 1003 | 1010 |
| 1004 FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info, | 1011 FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info, |
| 1005 Utf16CharacterStream* source) { | 1012 Utf16CharacterStream* source) { |
| 1006 Handle<SharedFunctionInfo> shared_info = info->shared_info(); | 1013 Handle<SharedFunctionInfo> shared_info = info->shared_info(); |
| 1007 scanner_.Initialize(source); | 1014 scanner_.Initialize(source); |
| 1008 DCHECK(scope_ == NULL); | 1015 DCHECK(scope_ == NULL); |
| 1009 DCHECK(target_stack_ == NULL); | 1016 DCHECK(target_stack_ == NULL); |
| 1010 | 1017 |
| 1011 Handle<String> name(String::cast(shared_info->name())); | 1018 Handle<String> name(String::cast(shared_info->name())); |
| 1012 DCHECK(ast_value_factory()); | 1019 DCHECK(ast_value_factory()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1031 info->closure()->context(), scope); | 1038 info->closure()->context(), scope); |
| 1032 } | 1039 } |
| 1033 original_scope_ = scope; | 1040 original_scope_ = scope; |
| 1034 AstNodeFactory function_factory(ast_value_factory()); | 1041 AstNodeFactory function_factory(ast_value_factory()); |
| 1035 FunctionState function_state(&function_state_, &scope_, scope, | 1042 FunctionState function_state(&function_state_, &scope_, scope, |
| 1036 shared_info->kind(), &function_factory); | 1043 shared_info->kind(), &function_factory); |
| 1037 DCHECK(is_sloppy(scope->language_mode()) || | 1044 DCHECK(is_sloppy(scope->language_mode()) || |
| 1038 is_strict(info->language_mode())); | 1045 is_strict(info->language_mode())); |
| 1039 DCHECK(info->language_mode() == shared_info->language_mode()); | 1046 DCHECK(info->language_mode() == shared_info->language_mode()); |
| 1040 FunctionLiteral::FunctionType function_type = | 1047 FunctionLiteral::FunctionType function_type = |
| 1041 shared_info->is_expression() | 1048 ComputeFunctionType(shared_info); |
| 1042 ? (shared_info->is_anonymous() | |
| 1043 ? FunctionLiteral::kAnonymousExpression | |
| 1044 : FunctionLiteral::kNamedExpression) | |
| 1045 : FunctionLiteral::kDeclaration; | |
| 1046 bool ok = true; | 1049 bool ok = true; |
| 1047 | 1050 |
| 1048 if (shared_info->is_arrow()) { | 1051 if (shared_info->is_arrow()) { |
| 1049 // TODO(adamk): We should construct this scope from the ScopeInfo. | 1052 // TODO(adamk): We should construct this scope from the ScopeInfo. |
| 1050 Scope* scope = | 1053 Scope* scope = |
| 1051 NewScope(scope_, FUNCTION_SCOPE, FunctionKind::kArrowFunction); | 1054 NewScope(scope_, FUNCTION_SCOPE, FunctionKind::kArrowFunction); |
| 1052 | 1055 |
| 1053 // These two bits only need to be explicitly set because we're | 1056 // These two bits only need to be explicitly set because we're |
| 1054 // not passing the ScopeInfo to the Scope constructor. | 1057 // not passing the ScopeInfo to the Scope constructor. |
| 1055 // TODO(adamk): Remove these calls once the above NewScope call | 1058 // TODO(adamk): Remove these calls once the above NewScope call |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 ok = false; | 1107 ok = false; |
| 1105 } | 1108 } |
| 1106 } | 1109 } |
| 1107 } | 1110 } |
| 1108 } else if (shared_info->is_default_constructor()) { | 1111 } else if (shared_info->is_default_constructor()) { |
| 1109 result = DefaultConstructor( | 1112 result = DefaultConstructor( |
| 1110 raw_name, IsSubclassConstructor(shared_info->kind()), scope, | 1113 raw_name, IsSubclassConstructor(shared_info->kind()), scope, |
| 1111 shared_info->start_position(), shared_info->end_position(), | 1114 shared_info->start_position(), shared_info->end_position(), |
| 1112 shared_info->language_mode()); | 1115 shared_info->language_mode()); |
| 1113 } else { | 1116 } else { |
| 1114 result = ParseFunctionLiteral( | 1117 result = ParseFunctionLiteral(raw_name, Scanner::Location::invalid(), |
| 1115 raw_name, Scanner::Location::invalid(), kSkipFunctionNameCheck, | 1118 kSkipFunctionNameCheck, shared_info->kind(), |
| 1116 shared_info->kind(), RelocInfo::kNoPosition, function_type, | 1119 RelocInfo::kNoPosition, function_type, |
| 1117 FunctionLiteral::kNormalArity, shared_info->language_mode(), &ok); | 1120 shared_info->language_mode(), &ok); |
| 1118 } | 1121 } |
| 1119 // Make sure the results agree. | 1122 // Make sure the results agree. |
| 1120 DCHECK(ok == (result != NULL)); | 1123 DCHECK(ok == (result != NULL)); |
| 1121 } | 1124 } |
| 1122 | 1125 |
| 1123 // Make sure the target stack is empty. | 1126 // Make sure the target stack is empty. |
| 1124 DCHECK(target_stack_ == NULL); | 1127 DCHECK(target_stack_ == NULL); |
| 1125 | 1128 |
| 1126 if (result != NULL) { | 1129 if (result != NULL) { |
| 1127 Handle<String> inferred_name(shared_info->inferred_name()); | 1130 Handle<String> inferred_name(shared_info->inferred_name()); |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 // FunctionDeclaration[+Default] :: | 1574 // FunctionDeclaration[+Default] :: |
| 1572 // 'function' '(' FormalParameters ')' '{' FunctionBody '}' | 1575 // 'function' '(' FormalParameters ')' '{' FunctionBody '}' |
| 1573 // | 1576 // |
| 1574 // GeneratorDeclaration[+Default] :: | 1577 // GeneratorDeclaration[+Default] :: |
| 1575 // 'function' '*' '(' FormalParameters ')' '{' FunctionBody '}' | 1578 // 'function' '*' '(' FormalParameters ')' '{' FunctionBody '}' |
| 1576 default_export = ParseFunctionLiteral( | 1579 default_export = ParseFunctionLiteral( |
| 1577 default_string, Scanner::Location::invalid(), | 1580 default_string, Scanner::Location::invalid(), |
| 1578 kSkipFunctionNameCheck, | 1581 kSkipFunctionNameCheck, |
| 1579 is_generator ? FunctionKind::kGeneratorFunction | 1582 is_generator ? FunctionKind::kGeneratorFunction |
| 1580 : FunctionKind::kNormalFunction, | 1583 : FunctionKind::kNormalFunction, |
| 1581 pos, FunctionLiteral::kDeclaration, FunctionLiteral::kNormalArity, | 1584 pos, FunctionLiteral::kDeclaration, language_mode(), CHECK_OK); |
| 1582 language_mode(), CHECK_OK); | |
| 1583 result = factory()->NewEmptyStatement(RelocInfo::kNoPosition); | 1585 result = factory()->NewEmptyStatement(RelocInfo::kNoPosition); |
| 1584 } else { | 1586 } else { |
| 1585 result = ParseFunctionDeclaration(pos, is_generator, &names, CHECK_OK); | 1587 result = ParseFunctionDeclaration(pos, is_generator, &names, CHECK_OK); |
| 1586 } | 1588 } |
| 1587 break; | 1589 break; |
| 1588 } | 1590 } |
| 1589 | 1591 |
| 1590 case Token::CLASS: | 1592 case Token::CLASS: |
| 1591 Consume(Token::CLASS); | 1593 Consume(Token::CLASS); |
| 1592 if (peek() == Token::EXTENDS || peek() == Token::LBRACE) { | 1594 if (peek() == Token::EXTENDS || peek() == Token::LBRACE) { |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2143 &is_strict_reserved, CHECK_OK); | 2145 &is_strict_reserved, CHECK_OK); |
| 2144 | 2146 |
| 2145 FuncNameInferrer::State fni_state(fni_); | 2147 FuncNameInferrer::State fni_state(fni_); |
| 2146 if (fni_ != NULL) fni_->PushEnclosingName(name); | 2148 if (fni_ != NULL) fni_->PushEnclosingName(name); |
| 2147 FunctionLiteral* fun = ParseFunctionLiteral( | 2149 FunctionLiteral* fun = ParseFunctionLiteral( |
| 2148 name, scanner()->location(), | 2150 name, scanner()->location(), |
| 2149 is_strict_reserved ? kFunctionNameIsStrictReserved | 2151 is_strict_reserved ? kFunctionNameIsStrictReserved |
| 2150 : kFunctionNameValidityUnknown, | 2152 : kFunctionNameValidityUnknown, |
| 2151 is_generator ? FunctionKind::kGeneratorFunction | 2153 is_generator ? FunctionKind::kGeneratorFunction |
| 2152 : FunctionKind::kNormalFunction, | 2154 : FunctionKind::kNormalFunction, |
| 2153 pos, FunctionLiteral::kDeclaration, FunctionLiteral::kNormalArity, | 2155 pos, FunctionLiteral::kDeclaration, language_mode(), CHECK_OK); |
| 2154 language_mode(), CHECK_OK); | |
| 2155 | 2156 |
| 2156 // Even if we're not at the top-level of the global or a function | 2157 // Even if we're not at the top-level of the global or a function |
| 2157 // scope, we treat it as such and introduce the function with its | 2158 // scope, we treat it as such and introduce the function with its |
| 2158 // initial value upon entering the corresponding scope. | 2159 // initial value upon entering the corresponding scope. |
| 2159 // In ES6, a function behaves as a lexical binding, except in | 2160 // In ES6, a function behaves as a lexical binding, except in |
| 2160 // a script scope, or the initial scope of eval or another function. | 2161 // a script scope, or the initial scope of eval or another function. |
| 2161 VariableMode mode = | 2162 VariableMode mode = |
| 2162 is_strong(language_mode()) | 2163 is_strong(language_mode()) |
| 2163 ? CONST | 2164 ? CONST |
| 2164 : (is_strict(language_mode()) || allow_harmony_sloppy_function()) && | 2165 : (is_strict(language_mode()) || allow_harmony_sloppy_function()) && |
| (...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4139 DCHECK(reindexer.count() <= | 4140 DCHECK(reindexer.count() <= |
| 4140 parser_->function_state_->materialized_literal_count()); | 4141 parser_->function_state_->materialized_literal_count()); |
| 4141 } | 4142 } |
| 4142 } | 4143 } |
| 4143 | 4144 |
| 4144 | 4145 |
| 4145 FunctionLiteral* Parser::ParseFunctionLiteral( | 4146 FunctionLiteral* Parser::ParseFunctionLiteral( |
| 4146 const AstRawString* function_name, Scanner::Location function_name_location, | 4147 const AstRawString* function_name, Scanner::Location function_name_location, |
| 4147 FunctionNameValidity function_name_validity, FunctionKind kind, | 4148 FunctionNameValidity function_name_validity, FunctionKind kind, |
| 4148 int function_token_pos, FunctionLiteral::FunctionType function_type, | 4149 int function_token_pos, FunctionLiteral::FunctionType function_type, |
| 4149 FunctionLiteral::ArityRestriction arity_restriction, | |
| 4150 LanguageMode language_mode, bool* ok) { | 4150 LanguageMode language_mode, bool* ok) { |
| 4151 // Function :: | 4151 // Function :: |
| 4152 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 4152 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
| 4153 // | 4153 // |
| 4154 // Getter :: | 4154 // Getter :: |
| 4155 // '(' ')' '{' FunctionBody '}' | 4155 // '(' ')' '{' FunctionBody '}' |
| 4156 // | 4156 // |
| 4157 // Setter :: | 4157 // Setter :: |
| 4158 // '(' PropertySetParameterList ')' '{' FunctionBody '}' | 4158 // '(' PropertySetParameterList ')' '{' FunctionBody '}' |
| 4159 | 4159 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4242 | 4242 |
| 4243 Expect(Token::LPAREN, CHECK_OK); | 4243 Expect(Token::LPAREN, CHECK_OK); |
| 4244 int start_position = scanner()->location().beg_pos; | 4244 int start_position = scanner()->location().beg_pos; |
| 4245 scope_->set_start_position(start_position); | 4245 scope_->set_start_position(start_position); |
| 4246 ParserFormalParameters formals(scope); | 4246 ParserFormalParameters formals(scope); |
| 4247 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); | 4247 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); |
| 4248 arity = formals.Arity(); | 4248 arity = formals.Arity(); |
| 4249 Expect(Token::RPAREN, CHECK_OK); | 4249 Expect(Token::RPAREN, CHECK_OK); |
| 4250 int formals_end_position = scanner()->location().end_pos; | 4250 int formals_end_position = scanner()->location().end_pos; |
| 4251 | 4251 |
| 4252 CheckArityRestrictions(arity, arity_restriction, | 4252 CheckArityRestrictions(arity, kind, formals.has_rest, start_position, |
| 4253 formals.has_rest, start_position, | |
| 4254 formals_end_position, CHECK_OK); | 4253 formals_end_position, CHECK_OK); |
| 4255 Expect(Token::LBRACE, CHECK_OK); | 4254 Expect(Token::LBRACE, CHECK_OK); |
| 4256 | 4255 |
| 4257 // Don't include the rest parameter into the function's formal parameter | 4256 // Don't include the rest parameter into the function's formal parameter |
| 4258 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count, | 4257 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count, |
| 4259 // which says whether we need to create an arguments adaptor frame). | 4258 // which says whether we need to create an arguments adaptor frame). |
| 4260 if (formals.has_rest) arity--; | 4259 if (formals.has_rest) arity--; |
| 4261 | 4260 |
| 4262 // Determine if the function can be parsed lazily. Lazy parsing is different | 4261 // Determine if the function can be parsed lazily. Lazy parsing is different |
| 4263 // from lazy compilation; we need to parse more eagerly than we compile. | 4262 // from lazy compilation; we need to parse more eagerly than we compile. |
| (...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5751 void ParserTraits::QueueDestructuringAssignmentForRewriting(Expression* expr) { | 5750 void ParserTraits::QueueDestructuringAssignmentForRewriting(Expression* expr) { |
| 5752 DCHECK(expr->IsRewritableAssignmentExpression()); | 5751 DCHECK(expr->IsRewritableAssignmentExpression()); |
| 5753 parser_->function_state_->AddDestructuringAssignment( | 5752 parser_->function_state_->AddDestructuringAssignment( |
| 5754 Parser::DestructuringAssignment(expr, parser_->scope_)); | 5753 Parser::DestructuringAssignment(expr, parser_->scope_)); |
| 5755 } | 5754 } |
| 5756 | 5755 |
| 5757 | 5756 |
| 5758 void ParserTraits::SetFunctionNameFromPropertyName( | 5757 void ParserTraits::SetFunctionNameFromPropertyName( |
| 5759 ObjectLiteralProperty* property, const AstRawString* name) { | 5758 ObjectLiteralProperty* property, const AstRawString* name) { |
| 5760 Expression* value = property->value(); | 5759 Expression* value = property->value(); |
| 5761 if (!value->IsAnonymousFunctionDefinition()) return; | |
| 5762 | 5760 |
| 5763 // Computed name setting must happen at runtime. | 5761 // Computed name setting must happen at runtime. |
| 5764 if (property->is_computed_name()) return; | 5762 if (property->is_computed_name()) return; |
| 5765 | 5763 |
| 5764 // Getter and setter names are handled here because their names |
| 5765 // change in ES2015, even though they are not anonymous. |
| 5766 auto function = value->AsFunctionLiteral(); |
| 5767 if (function != nullptr) { |
| 5768 bool is_getter = property->kind() == ObjectLiteralProperty::GETTER; |
| 5769 bool is_setter = property->kind() == ObjectLiteralProperty::SETTER; |
| 5770 if (is_getter || is_setter) { |
| 5771 DCHECK_NOT_NULL(name); |
| 5772 const AstRawString* prefix = |
| 5773 is_getter ? parser_->ast_value_factory()->get_space_string() |
| 5774 : parser_->ast_value_factory()->set_space_string(); |
| 5775 function->set_raw_name( |
| 5776 parser_->ast_value_factory()->NewConsString(prefix, name)); |
| 5777 return; |
| 5778 } |
| 5779 } |
| 5780 |
| 5781 if (!value->IsAnonymousFunctionDefinition()) return; |
| 5766 DCHECK_NOT_NULL(name); | 5782 DCHECK_NOT_NULL(name); |
| 5767 | 5783 |
| 5768 // Ignore "__proto__" as a name when it's being used to set the [[Prototype]] | 5784 // Ignore "__proto__" as a name when it's being used to set the [[Prototype]] |
| 5769 // of an object literal. | 5785 // of an object literal. |
| 5770 if (property->kind() == ObjectLiteralProperty::PROTOTYPE) return; | 5786 if (property->kind() == ObjectLiteralProperty::PROTOTYPE) return; |
| 5771 | 5787 |
| 5772 auto function = value->AsFunctionLiteral(); | |
| 5773 if (function != nullptr) { | 5788 if (function != nullptr) { |
| 5774 if (property->kind() == ObjectLiteralProperty::GETTER) { | 5789 function->set_raw_name(name); |
| 5775 function->set_raw_name(parser_->ast_value_factory()->NewConsString( | 5790 DCHECK_EQ(ObjectLiteralProperty::COMPUTED, property->kind()); |
| 5776 parser_->ast_value_factory()->get_space_string(), name)); | |
| 5777 } else if (property->kind() == ObjectLiteralProperty::SETTER) { | |
| 5778 function->set_raw_name(parser_->ast_value_factory()->NewConsString( | |
| 5779 parser_->ast_value_factory()->set_space_string(), name)); | |
| 5780 } else { | |
| 5781 function->set_raw_name(name); | |
| 5782 DCHECK_EQ(ObjectLiteralProperty::COMPUTED, property->kind()); | |
| 5783 } | |
| 5784 } else { | 5791 } else { |
| 5785 DCHECK(value->IsClassLiteral()); | 5792 DCHECK(value->IsClassLiteral()); |
| 5786 DCHECK_EQ(ObjectLiteralProperty::COMPUTED, property->kind()); | 5793 DCHECK_EQ(ObjectLiteralProperty::COMPUTED, property->kind()); |
| 5787 value->AsClassLiteral()->constructor()->set_raw_name(name); | 5794 value->AsClassLiteral()->constructor()->set_raw_name(name); |
| 5788 } | 5795 } |
| 5789 } | 5796 } |
| 5790 | 5797 |
| 5791 | 5798 |
| 5792 void ParserTraits::SetFunctionNameFromIdentifierRef(Expression* value, | 5799 void ParserTraits::SetFunctionNameFromIdentifierRef(Expression* value, |
| 5793 Expression* identifier) { | 5800 Expression* identifier) { |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6727 new_body->statements()->Add(loop->body(), zone); | 6734 new_body->statements()->Add(loop->body(), zone); |
| 6728 new_body->statements()->Add(set_completion_normal, zone); | 6735 new_body->statements()->Add(set_completion_normal, zone); |
| 6729 | 6736 |
| 6730 loop->set_body(new_body); | 6737 loop->set_body(new_body); |
| 6731 return final_loop; | 6738 return final_loop; |
| 6732 } | 6739 } |
| 6733 | 6740 |
| 6734 | 6741 |
| 6735 } // namespace internal | 6742 } // namespace internal |
| 6736 } // namespace v8 | 6743 } // namespace v8 |
| OLD | NEW |