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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1127 ? FunctionLiteral::ANONYMOUS_EXPRESSION | 1127 ? FunctionLiteral::ANONYMOUS_EXPRESSION |
1128 : FunctionLiteral::NAMED_EXPRESSION) | 1128 : FunctionLiteral::NAMED_EXPRESSION) |
1129 : FunctionLiteral::DECLARATION; | 1129 : FunctionLiteral::DECLARATION; |
1130 bool ok = true; | 1130 bool ok = true; |
1131 | 1131 |
1132 if (shared_info->is_arrow()) { | 1132 if (shared_info->is_arrow()) { |
1133 Scope* scope = NewScope(scope_, ARROW_SCOPE); | 1133 Scope* scope = NewScope(scope_, ARROW_SCOPE); |
1134 scope->set_start_position(shared_info->start_position()); | 1134 scope->set_start_position(shared_info->start_position()); |
1135 FormalParameterErrorLocations error_locs; | 1135 FormalParameterErrorLocations error_locs; |
1136 bool has_rest = false; | 1136 bool has_rest = false; |
1137 bool has_initializers = false; | |
1138 ZoneList<Expression*>* initializers = | |
1139 new (zone()) ZoneList<Expression*>(0, zone()); | |
1137 if (Check(Token::LPAREN)) { | 1140 if (Check(Token::LPAREN)) { |
1138 // '(' StrictFormalParameters ')' | 1141 // '(' StrictFormalParameters ')' |
1139 ParseFormalParameterList(scope, &error_locs, &has_rest, &ok); | 1142 ParseFormalParameterList(scope, &error_locs, initializers, |
1143 &has_initializers, &has_rest, &ok); | |
1140 if (ok) ok = Check(Token::RPAREN); | 1144 if (ok) ok = Check(Token::RPAREN); |
1141 } else { | 1145 } else { |
1142 // BindingIdentifier | 1146 // BindingIdentifier |
1143 ParseFormalParameter(scope, &error_locs, has_rest, &ok); | 1147 ParseFormalParameter(scope, &error_locs, nullptr, nullptr, has_rest, |
1148 &ok); | |
1144 } | 1149 } |
1145 | 1150 |
1146 if (ok) { | 1151 if (ok) { |
1147 ExpressionClassifier classifier; | 1152 ExpressionClassifier classifier; |
1148 Expression* expression = ParseArrowFunctionLiteral( | 1153 Expression* expression = ParseArrowFunctionLiteral( |
1149 scope, error_locs, has_rest, &classifier, &ok); | 1154 scope, error_locs, has_rest, &classifier, &ok); |
1150 ValidateExpression(&classifier, &ok); | 1155 ValidateExpression(&classifier, &ok); |
1151 if (ok) { | 1156 if (ok) { |
1152 // Scanning must end at the same position that was recorded | 1157 // Scanning must end at the same position that was recorded |
1153 // previously. If not, parsing has been interrupted due to a stack | 1158 // previously. If not, parsing has been interrupted due to a stack |
(...skipping 2802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3956 // TODO(wingo): Make a better message. | 3961 // TODO(wingo): Make a better message. |
3957 ReportMessageAt(params_loc, "malformed_arrow_function_parameter_list"); | 3962 ReportMessageAt(params_loc, "malformed_arrow_function_parameter_list"); |
3958 *ok = false; | 3963 *ok = false; |
3959 return; | 3964 return; |
3960 } | 3965 } |
3961 | 3966 |
3962 DeclareArrowFunctionParameters(scope, params, params_loc, error_locs, ok); | 3967 DeclareArrowFunctionParameters(scope, params, params_loc, error_locs, ok); |
3963 } | 3968 } |
3964 | 3969 |
3965 | 3970 |
3971 ZoneList<Statement*>* Parser::DesugarInitializeParameters( | |
3972 Scope* scope, bool has_initializers, ZoneList<Expression*>* initializers) { | |
3973 ZoneList<Statement*>* body = new (zone()) ZoneList<Statement*>(0, zone()); | |
3974 if (has_initializers) { | |
3975 for (int i = 0; i < initializers->length(); ++i) { | |
3976 Expression* initializer = initializers->at(i); | |
3977 // TODO(caitp): ensure proper TDZ behaviour --- need hole-check for | |
3978 // all parameter bindings, including ones without initializers | |
3979 if (initializer) { | |
3980 // IS_UNDEFINED(%_Arguments(i)) ? <initializer> : %_Arguments(i); | |
3981 const AstRawString* fn_name = ast_value_factory()->empty_string(); | |
3982 const Runtime::Function* arguments = | |
3983 Runtime::FunctionForId(Runtime::kInlineArguments); | |
3984 ZoneList<Expression*>* arguments_i0 = | |
3985 new (zone()) ZoneList<Expression*>(0, zone()); | |
3986 arguments_i0->Add(factory()->NewSmiLiteral(i, RelocInfo::kNoPosition), | |
3987 zone()); | |
3988 | |
3989 ZoneList<Expression*>* arguments_i1 = | |
3990 new (zone()) ZoneList<Expression*>(0, zone()); | |
3991 arguments_i1->Add(factory()->NewSmiLiteral(i, RelocInfo::kNoPosition), | |
3992 zone()); | |
3993 | |
3994 Expression* arg_or_default = factory()->NewConditional( | |
3995 // condition: | |
3996 factory()->NewCompareOperation( | |
3997 Token::EQ_STRICT, | |
3998 factory()->NewCallRuntime(fn_name, arguments, arguments_i0, | |
3999 RelocInfo::kNoPosition), | |
4000 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), | |
4001 RelocInfo::kNoPosition), | |
4002 // if true: | |
4003 initializer, | |
4004 // if false: | |
4005 factory()->NewCallRuntime(fn_name, arguments, arguments_i1, | |
4006 RelocInfo::kNoPosition), | |
4007 RelocInfo::kNoPosition); | |
4008 | |
4009 Expression* assign = factory()->NewAssignment( | |
4010 Token::ASSIGN, factory()->NewVariableProxy(scope->parameter(i), | |
arv (Not doing code reviews)
2015/05/01 18:31:32
Will this work correctly if someone accesses the a
| |
4011 RelocInfo::kNoPosition), | |
4012 arg_or_default, RelocInfo::kNoPosition); | |
4013 | |
4014 body->Add( | |
4015 factory()->NewExpressionStatement(assign, RelocInfo::kNoPosition), | |
4016 zone()); | |
4017 } | |
4018 } | |
4019 } | |
4020 return body; | |
4021 } | |
4022 | |
4023 | |
3966 FunctionLiteral* Parser::ParseFunctionLiteral( | 4024 FunctionLiteral* Parser::ParseFunctionLiteral( |
3967 const AstRawString* function_name, Scanner::Location function_name_location, | 4025 const AstRawString* function_name, Scanner::Location function_name_location, |
3968 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 4026 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
3969 FunctionLiteral::FunctionType function_type, | 4027 FunctionLiteral::FunctionType function_type, |
3970 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { | 4028 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { |
3971 // Function :: | 4029 // Function :: |
3972 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 4030 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
3973 // | 4031 // |
3974 // Getter :: | 4032 // Getter :: |
3975 // '(' ')' '{' FunctionBody '}' | 4033 // '(' ')' '{' FunctionBody '}' |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4021 // compiling a function in an inner declaration scope in the eval, e.g. a | 4079 // compiling a function in an inner declaration scope in the eval, e.g. a |
4022 // nested function, and hoisting works normally relative to that. | 4080 // nested function, and hoisting works normally relative to that. |
4023 Scope* declaration_scope = scope_->DeclarationScope(); | 4081 Scope* declaration_scope = scope_->DeclarationScope(); |
4024 Scope* original_declaration_scope = original_scope_->DeclarationScope(); | 4082 Scope* original_declaration_scope = original_scope_->DeclarationScope(); |
4025 Scope* scope = function_type == FunctionLiteral::DECLARATION && | 4083 Scope* scope = function_type == FunctionLiteral::DECLARATION && |
4026 is_sloppy(language_mode()) && | 4084 is_sloppy(language_mode()) && |
4027 (original_scope_ == original_declaration_scope || | 4085 (original_scope_ == original_declaration_scope || |
4028 declaration_scope != original_declaration_scope) | 4086 declaration_scope != original_declaration_scope) |
4029 ? NewScope(declaration_scope, FUNCTION_SCOPE, kind) | 4087 ? NewScope(declaration_scope, FUNCTION_SCOPE, kind) |
4030 : NewScope(scope_, FUNCTION_SCOPE, kind); | 4088 : NewScope(scope_, FUNCTION_SCOPE, kind); |
4089 Scope* function_body = NewScope(scope, FUNCTION_BODY_SCOPE); | |
arv (Not doing code reviews)
2015/05/01 18:31:32
rename to function_body_scope
| |
4090 DCHECK_EQ(scope->function_body(), function_body); | |
4031 ZoneList<Statement*>* body = NULL; | 4091 ZoneList<Statement*>* body = NULL; |
4032 int materialized_literal_count = -1; | 4092 int materialized_literal_count = -1; |
4033 int expected_property_count = -1; | 4093 int expected_property_count = -1; |
4034 int handler_count = 0; | 4094 int handler_count = 0; |
4035 FormalParameterErrorLocations error_locs; | 4095 FormalParameterErrorLocations error_locs; |
4036 FunctionLiteral::EagerCompileHint eager_compile_hint = | 4096 FunctionLiteral::EagerCompileHint eager_compile_hint = |
4037 parenthesized_function_ ? FunctionLiteral::kShouldEagerCompile | 4097 parenthesized_function_ ? FunctionLiteral::kShouldEagerCompile |
4038 : FunctionLiteral::kShouldLazyCompile; | 4098 : FunctionLiteral::kShouldLazyCompile; |
4039 // Parse function body. | 4099 // Parse function body. |
4040 { | 4100 { |
4041 AstNodeFactory function_factory(ast_value_factory()); | 4101 AstNodeFactory function_factory(ast_value_factory()); |
4042 FunctionState function_state(&function_state_, &scope_, scope, kind, | 4102 FunctionState function_state(&function_state_, &scope_, scope, kind, |
4043 &function_factory); | 4103 &function_factory); |
4044 scope_->SetScopeName(function_name); | 4104 scope_->SetScopeName(function_name); |
4105 function_body->SetScopeName(function_name); | |
4045 | 4106 |
4046 if (is_generator) { | 4107 if (is_generator) { |
4047 // For generators, allocating variables in contexts is currently a win | 4108 // For generators, allocating variables in contexts is currently a win |
4048 // because it minimizes the work needed to suspend and resume an | 4109 // because it minimizes the work needed to suspend and resume an |
4049 // activation. | 4110 // activation. |
4050 scope_->ForceContextAllocation(); | 4111 scope_->ForceContextAllocation(); |
4051 | 4112 |
4052 // Calling a generator returns a generator object. That object is stored | 4113 // Calling a generator returns a generator object. That object is stored |
4053 // in a temporary variable, a definition that is used by "yield" | 4114 // in a temporary variable, a definition that is used by "yield" |
4054 // expressions. This also marks the FunctionState as a generator. | 4115 // expressions. This also marks the FunctionState as a generator. |
4055 Variable* temp = scope_->DeclarationScope()->NewTemporary( | 4116 Variable* temp = scope_->DeclarationScope()->NewTemporary( |
4056 ast_value_factory()->dot_generator_object_string()); | 4117 ast_value_factory()->dot_generator_object_string()); |
4057 function_state.set_generator_object_variable(temp); | 4118 function_state.set_generator_object_variable(temp); |
4058 } | 4119 } |
4059 | 4120 |
4060 bool has_rest = false; | 4121 bool has_rest = false; |
4061 Expect(Token::LPAREN, CHECK_OK); | 4122 Expect(Token::LPAREN, CHECK_OK); |
4062 int start_position = scanner()->location().beg_pos; | 4123 int start_position = scanner()->location().beg_pos; |
4063 scope_->set_start_position(start_position); | 4124 scope_->set_start_position(start_position); |
4125 function_body->set_start_position(start_position); | |
4126 ZoneList<Expression*>* initializers = | |
4127 new (zone()) ZoneList<Expression*>(0, zone()); | |
4128 bool has_initializers = false; | |
4064 num_parameters = | 4129 num_parameters = |
4065 ParseFormalParameterList(scope, &error_locs, &has_rest, CHECK_OK); | 4130 ParseFormalParameterList(scope, &error_locs, initializers, |
4131 &has_initializers, &has_rest, CHECK_OK); | |
4066 Expect(Token::RPAREN, CHECK_OK); | 4132 Expect(Token::RPAREN, CHECK_OK); |
4067 int formals_end_position = scanner()->location().end_pos; | 4133 int formals_end_position = scanner()->location().end_pos; |
4068 | 4134 |
4069 CheckArityRestrictions(num_parameters, arity_restriction, start_position, | 4135 CheckArityRestrictions(num_parameters, arity_restriction, start_position, |
4070 formals_end_position, CHECK_OK); | 4136 formals_end_position, CHECK_OK); |
4071 | 4137 |
4072 Expect(Token::LBRACE, CHECK_OK); | 4138 Expect(Token::LBRACE, CHECK_OK); |
4073 | 4139 |
4074 // If we have a named function expression, we add a local variable | 4140 // If we have a named function expression, we add a local variable |
4075 // declaration to the body of the function with the name of the | 4141 // declaration to the body of the function with the name of the |
4076 // function and let it refer to the function itself (closure). | 4142 // function and let it refer to the function itself (closure). |
4077 // NOTE: We create a proxy and resolve it here so that in the | 4143 // NOTE: We create a proxy and resolve it here so that in the |
4078 // future we can change the AST to only refer to VariableProxies | 4144 // future we can change the AST to only refer to VariableProxies |
4079 // instead of Variables and Proxis as is the case now. | 4145 // instead of Variables and Proxis as is the case now. |
4080 Variable* fvar = NULL; | 4146 Variable* fvar = NULL; |
4081 Token::Value fvar_init_op = Token::INIT_CONST_LEGACY; | 4147 Token::Value fvar_init_op = Token::INIT_CONST_LEGACY; |
4082 if (function_type == FunctionLiteral::NAMED_EXPRESSION) { | 4148 if (function_type == FunctionLiteral::NAMED_EXPRESSION) { |
4083 if (is_strict(language_mode())) { | 4149 if (is_strict(language_mode())) { |
4084 fvar_init_op = Token::INIT_CONST; | 4150 fvar_init_op = Token::INIT_CONST; |
4085 } | 4151 } |
4086 VariableMode fvar_mode = | 4152 VariableMode fvar_mode = |
4087 is_strict(language_mode()) ? CONST : CONST_LEGACY; | 4153 is_strict(language_mode()) ? CONST : CONST_LEGACY; |
4088 DCHECK(function_name != NULL); | 4154 DCHECK(function_name != NULL); |
4089 fvar = new (zone()) | 4155 fvar = new (zone()) |
4090 Variable(scope_, function_name, fvar_mode, Variable::NORMAL, | 4156 Variable(scope_, function_name, fvar_mode, Variable::NORMAL, |
4091 kCreatedInitialized, kNotAssigned); | 4157 kCreatedInitialized, kNotAssigned); |
4092 VariableProxy* proxy = factory()->NewVariableProxy(fvar); | 4158 VariableProxy* proxy = factory()->NewVariableProxy(fvar); |
4093 VariableDeclaration* fvar_declaration = factory()->NewVariableDeclaration( | 4159 VariableDeclaration* fvar_declaration = factory()->NewVariableDeclaration( |
4094 proxy, fvar_mode, scope_, RelocInfo::kNoPosition); | 4160 proxy, fvar_mode, scope_, RelocInfo::kNoPosition); |
4161 DCHECK(scope_->is_function_scope()); | |
4095 scope_->DeclareFunctionVar(fvar_declaration); | 4162 scope_->DeclareFunctionVar(fvar_declaration); |
4096 } | 4163 } |
4097 | 4164 |
4098 // Determine if the function can be parsed lazily. Lazy parsing is different | 4165 // Determine if the function can be parsed lazily. Lazy parsing is different |
4099 // from lazy compilation; we need to parse more eagerly than we compile. | 4166 // from lazy compilation; we need to parse more eagerly than we compile. |
4100 | 4167 |
4101 // We can only parse lazily if we also compile lazily. The heuristics for | 4168 // We can only parse lazily if we also compile lazily. The heuristics for |
4102 // lazy compilation are: | 4169 // lazy compilation are: |
4103 // - It must not have been prohibited by the caller to Parse (some callers | 4170 // - It must not have been prohibited by the caller to Parse (some callers |
4104 // need a full AST). | 4171 // need a full AST). |
(...skipping 21 matching lines...) Expand all Loading... | |
4126 // possible reference to the variable in foo's scope. However, it's possible | 4193 // possible reference to the variable in foo's scope. However, it's possible |
4127 // that it will be compiled lazily. | 4194 // that it will be compiled lazily. |
4128 | 4195 |
4129 // To make this additional case work, both Parser and PreParser implement a | 4196 // To make this additional case work, both Parser and PreParser implement a |
4130 // logic where only top-level functions will be parsed lazily. | 4197 // logic where only top-level functions will be parsed lazily. |
4131 bool is_lazily_parsed = (mode() == PARSE_LAZILY && | 4198 bool is_lazily_parsed = (mode() == PARSE_LAZILY && |
4132 scope_->AllowsLazyCompilation() && | 4199 scope_->AllowsLazyCompilation() && |
4133 !parenthesized_function_); | 4200 !parenthesized_function_); |
4134 parenthesized_function_ = false; // The bit was set for this function only. | 4201 parenthesized_function_ = false; // The bit was set for this function only. |
4135 | 4202 |
4136 if (is_lazily_parsed) { | 4203 { |
4137 for (Scope* s = scope_->outer_scope(); | 4204 // Use the FUNCTION_BODY scope only if it's needed |
4138 s != nullptr && (s != s->DeclarationScope()); s = s->outer_scope()) { | 4205 // TODO(caitp): This is needed when ObjectBindingPatterns with |
4139 s->ForceContextAllocation(); | 4206 // computed property keys are used as well. |
4207 Scope* func_scope = has_initializers ? function_body : scope_; | |
4208 if (func_scope != function_body) { | |
arv (Not doing code reviews)
2015/05/01 18:31:32
use has_initializer instead?
caitp (gmail)
2015/05/01 19:03:35
Sure --- although note the comment above, it gets
| |
4209 function_body->FinalizeBlockScope(); | |
arv (Not doing code reviews)
2015/05/01 18:31:33
These are sibling scopes then?
caitp (gmail)
2015/05/01 19:03:35
function_body is a child of scope_ (the FUNCTION_S
| |
4140 } | 4210 } |
4141 SkipLazyFunctionBody(&materialized_literal_count, | 4211 BlockState function_body_state(&scope_, func_scope); |
4142 &expected_property_count, CHECK_OK); | 4212 if (is_lazily_parsed) { |
4143 } else { | 4213 for (Scope* s = scope_->outer_scope(); |
4144 body = ParseEagerFunctionBody(function_name, pos, fvar, fvar_init_op, | 4214 s != nullptr && (s != s->DeclarationScope()); |
4145 kind, CHECK_OK); | 4215 s = s->outer_scope()) { |
4146 materialized_literal_count = function_state.materialized_literal_count(); | 4216 s->ForceContextAllocation(); |
4147 expected_property_count = function_state.expected_property_count(); | 4217 } |
4148 handler_count = function_state.handler_count(); | 4218 SkipLazyFunctionBody(&materialized_literal_count, |
4219 &expected_property_count, CHECK_OK); | |
4220 } else { | |
4221 body = | |
4222 DesugarInitializeParameters(scope, has_initializers, initializers); | |
4223 ZoneList<Statement*>* inner_body = ParseEagerFunctionBody( | |
4224 function_name, pos, fvar, fvar_init_op, kind, CHECK_OK); | |
4225 body->AddAll(*inner_body, zone()); | |
4226 materialized_literal_count = | |
4227 function_state.materialized_literal_count(); | |
4228 expected_property_count = function_state.expected_property_count(); | |
4229 handler_count = function_state.handler_count(); | |
4149 | 4230 |
4150 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) { | 4231 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) { |
4151 if (!function_state.super_location().IsValid()) { | 4232 if (!function_state.super_location().IsValid()) { |
4152 ReportMessageAt(function_name_location, | 4233 ReportMessageAt(function_name_location, "strong_super_call_missing", |
4153 "strong_super_call_missing", kReferenceError); | 4234 kReferenceError); |
4154 *ok = false; | 4235 *ok = false; |
4155 return nullptr; | 4236 return nullptr; |
4237 } | |
4156 } | 4238 } |
4157 } | 4239 } |
4158 } | 4240 } |
4159 | 4241 |
4160 // Validate name and parameter names. We can do this only after parsing the | 4242 // Validate name and parameter names. We can do this only after parsing the |
4161 // function, since the function can declare itself strict. | 4243 // function, since the function can declare itself strict. |
4162 CheckFunctionName(language_mode(), kind, function_name, | 4244 CheckFunctionName(language_mode(), kind, function_name, |
4163 name_is_strict_reserved, function_name_location, | 4245 name_is_strict_reserved, function_name_location, |
4164 CHECK_OK); | 4246 CHECK_OK); |
4165 const bool use_strict_params = has_rest || IsConciseMethod(kind); | 4247 const bool use_strict_params = has_rest || IsConciseMethod(kind); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4237 return; | 4319 return; |
4238 } | 4320 } |
4239 if (logger.has_error()) { | 4321 if (logger.has_error()) { |
4240 ParserTraits::ReportMessageAt( | 4322 ParserTraits::ReportMessageAt( |
4241 Scanner::Location(logger.start(), logger.end()), logger.message(), | 4323 Scanner::Location(logger.start(), logger.end()), logger.message(), |
4242 logger.argument_opt(), logger.error_type()); | 4324 logger.argument_opt(), logger.error_type()); |
4243 *ok = false; | 4325 *ok = false; |
4244 return; | 4326 return; |
4245 } | 4327 } |
4246 scope_->set_end_position(logger.end()); | 4328 scope_->set_end_position(logger.end()); |
4329 if (scope_->is_function_body_scope()) { | |
4330 DCHECK(scope_->outer_scope()->is_function_scope()); | |
4331 scope_->outer_scope()->set_end_position(scanner()->location().end_pos); | |
4332 } | |
4247 Expect(Token::RBRACE, ok); | 4333 Expect(Token::RBRACE, ok); |
4248 if (!*ok) { | 4334 if (!*ok) { |
4249 return; | 4335 return; |
4250 } | 4336 } |
4251 total_preparse_skipped_ += scope_->end_position() - function_block_pos; | 4337 total_preparse_skipped_ += scope_->end_position() - function_block_pos; |
4252 *materialized_literal_count = logger.literals(); | 4338 *materialized_literal_count = logger.literals(); |
4253 *expected_property_count = logger.properties(); | 4339 *expected_property_count = logger.properties(); |
4254 scope_->SetLanguageMode(logger.language_mode()); | 4340 scope_->SetLanguageMode(logger.language_mode()); |
4255 if (logger.scope_uses_super_property()) { | 4341 if (logger.scope_uses_super_property()) { |
4256 scope_->RecordSuperPropertyUsage(); | 4342 scope_->RecordSuperPropertyUsage(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4345 if (IsSubclassConstructor(kind)) { | 4431 if (IsSubclassConstructor(kind)) { |
4346 body->Add( | 4432 body->Add( |
4347 factory()->NewReturnStatement( | 4433 factory()->NewReturnStatement( |
4348 this->ThisExpression(scope_, factory(), RelocInfo::kNoPosition), | 4434 this->ThisExpression(scope_, factory(), RelocInfo::kNoPosition), |
4349 RelocInfo::kNoPosition), | 4435 RelocInfo::kNoPosition), |
4350 zone()); | 4436 zone()); |
4351 } | 4437 } |
4352 | 4438 |
4353 Expect(Token::RBRACE, CHECK_OK); | 4439 Expect(Token::RBRACE, CHECK_OK); |
4354 scope_->set_end_position(scanner()->location().end_pos); | 4440 scope_->set_end_position(scanner()->location().end_pos); |
4441 if (scope_->is_function_body_scope()) { | |
4442 DCHECK(scope_->outer_scope()->is_function_scope()); | |
4443 scope_->outer_scope()->set_end_position(scanner()->location().end_pos); | |
4444 } | |
4355 | 4445 |
4356 return body; | 4446 return body; |
4357 } | 4447 } |
4358 | 4448 |
4359 | 4449 |
4360 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( | 4450 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( |
4361 SingletonLogger* logger) { | 4451 SingletonLogger* logger) { |
4362 // This function may be called on a background thread too; record only the | 4452 // This function may be called on a background thread too; record only the |
4363 // main thread preparse times. | 4453 // main thread preparse times. |
4364 if (pre_parse_timer_ != NULL) { | 4454 if (pre_parse_timer_ != NULL) { |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5891 | 5981 |
5892 Expression* Parser::SpreadCallNew(Expression* function, | 5982 Expression* Parser::SpreadCallNew(Expression* function, |
5893 ZoneList<v8::internal::Expression*>* args, | 5983 ZoneList<v8::internal::Expression*>* args, |
5894 int pos) { | 5984 int pos) { |
5895 args->InsertAt(0, function, zone()); | 5985 args->InsertAt(0, function, zone()); |
5896 | 5986 |
5897 return factory()->NewCallRuntime( | 5987 return factory()->NewCallRuntime( |
5898 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 5988 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
5899 } | 5989 } |
5900 } } // namespace v8::internal | 5990 } } // namespace v8::internal |
OLD | NEW |