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/ast-literal-reindexer.h" | 9 #include "src/ast-literal-reindexer.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 2810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2821 if (IsSubclassConstructor(function_state_->kind())) { | 2821 if (IsSubclassConstructor(function_state_->kind())) { |
2822 // For subclass constructors we need to return this in case of undefined | 2822 // For subclass constructors we need to return this in case of undefined |
2823 // and throw an exception in case of a non object. | 2823 // and throw an exception in case of a non object. |
2824 // | 2824 // |
2825 // return expr; | 2825 // return expr; |
2826 // | 2826 // |
2827 // Is rewritten as: | 2827 // Is rewritten as: |
2828 // | 2828 // |
2829 // return (temp = expr) === undefined ? this : | 2829 // return (temp = expr) === undefined ? this : |
2830 // %_IsSpecObject(temp) ? temp : throw new TypeError(...); | 2830 // %_IsSpecObject(temp) ? temp : throw new TypeError(...); |
2831 Variable* temp = scope_->DeclarationScope()->NewTemporary( | 2831 Variable* temp = scope_->TempScope()->NewTemporary( |
2832 ast_value_factory()->empty_string()); | 2832 ast_value_factory()->empty_string()); |
2833 Assignment* assign = factory()->NewAssignment( | 2833 Assignment* assign = factory()->NewAssignment( |
2834 Token::ASSIGN, factory()->NewVariableProxy(temp), return_value, pos); | 2834 Token::ASSIGN, factory()->NewVariableProxy(temp), return_value, pos); |
2835 | 2835 |
2836 Expression* throw_expression = | 2836 Expression* throw_expression = |
2837 NewThrowTypeError(MessageTemplate::kDerivedConstructorReturn, | 2837 NewThrowTypeError(MessageTemplate::kDerivedConstructorReturn, |
2838 ast_value_factory()->empty_string(), pos); | 2838 ast_value_factory()->empty_string(), pos); |
2839 | 2839 |
2840 // %_IsSpecObject(temp) | 2840 // %_IsSpecObject(temp) |
2841 ZoneList<Expression*>* is_spec_object_args = | 2841 ZoneList<Expression*>* is_spec_object_args = |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3175 } | 3175 } |
3176 | 3176 |
3177 | 3177 |
3178 void Parser::InitializeForEachStatement(ForEachStatement* stmt, | 3178 void Parser::InitializeForEachStatement(ForEachStatement* stmt, |
3179 Expression* each, | 3179 Expression* each, |
3180 Expression* subject, | 3180 Expression* subject, |
3181 Statement* body) { | 3181 Statement* body) { |
3182 ForOfStatement* for_of = stmt->AsForOfStatement(); | 3182 ForOfStatement* for_of = stmt->AsForOfStatement(); |
3183 | 3183 |
3184 if (for_of != NULL) { | 3184 if (for_of != NULL) { |
3185 Variable* iterator = scope_->DeclarationScope()->NewTemporary( | 3185 Variable* iterator = scope_->TempScope()->NewTemporary( |
3186 ast_value_factory()->dot_iterator_string()); | 3186 ast_value_factory()->dot_iterator_string()); |
3187 Variable* result = scope_->DeclarationScope()->NewTemporary( | 3187 Variable* result = scope_->TempScope()->NewTemporary( |
3188 ast_value_factory()->dot_result_string()); | 3188 ast_value_factory()->dot_result_string()); |
3189 | 3189 |
3190 Expression* assign_iterator; | 3190 Expression* assign_iterator; |
3191 Expression* next_result; | 3191 Expression* next_result; |
3192 Expression* result_done; | 3192 Expression* result_done; |
3193 Expression* assign_each; | 3193 Expression* assign_each; |
3194 | 3194 |
3195 // iterator = subject[Symbol.iterator]() | 3195 // iterator = subject[Symbol.iterator]() |
3196 assign_iterator = factory()->NewAssignment( | 3196 assign_iterator = factory()->NewAssignment( |
3197 Token::ASSIGN, factory()->NewVariableProxy(iterator), | 3197 Token::ASSIGN, factory()->NewVariableProxy(iterator), |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3293 | 3293 |
3294 // Add statement: let/const x = i. | 3294 // Add statement: let/const x = i. |
3295 outer_block->AddStatement(init, zone()); | 3295 outer_block->AddStatement(init, zone()); |
3296 | 3296 |
3297 const AstRawString* temp_name = ast_value_factory()->dot_for_string(); | 3297 const AstRawString* temp_name = ast_value_factory()->dot_for_string(); |
3298 | 3298 |
3299 // For each lexical variable x: | 3299 // For each lexical variable x: |
3300 // make statement: temp_x = x. | 3300 // make statement: temp_x = x. |
3301 for (int i = 0; i < names->length(); i++) { | 3301 for (int i = 0; i < names->length(); i++) { |
3302 VariableProxy* proxy = NewUnresolved(names->at(i), LET); | 3302 VariableProxy* proxy = NewUnresolved(names->at(i), LET); |
3303 Variable* temp = scope_->DeclarationScope()->NewTemporary(temp_name); | 3303 Variable* temp = scope_->TempScope()->NewTemporary(temp_name); |
3304 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp); | 3304 VariableProxy* temp_proxy = factory()->NewVariableProxy(temp); |
3305 Assignment* assignment = factory()->NewAssignment( | 3305 Assignment* assignment = factory()->NewAssignment( |
3306 Token::ASSIGN, temp_proxy, proxy, RelocInfo::kNoPosition); | 3306 Token::ASSIGN, temp_proxy, proxy, RelocInfo::kNoPosition); |
3307 Statement* assignment_statement = factory()->NewExpressionStatement( | 3307 Statement* assignment_statement = factory()->NewExpressionStatement( |
3308 assignment, RelocInfo::kNoPosition); | 3308 assignment, RelocInfo::kNoPosition); |
3309 outer_block->AddStatement(assignment_statement, zone()); | 3309 outer_block->AddStatement(assignment_statement, zone()); |
3310 temps.Add(temp, zone()); | 3310 temps.Add(temp, zone()); |
3311 } | 3311 } |
3312 | 3312 |
3313 Variable* first = NULL; | 3313 Variable* first = NULL; |
3314 // Make statement: first = 1. | 3314 // Make statement: first = 1. |
3315 if (next) { | 3315 if (next) { |
3316 first = scope_->DeclarationScope()->NewTemporary(temp_name); | 3316 first = scope_->TempScope()->NewTemporary(temp_name); |
3317 VariableProxy* first_proxy = factory()->NewVariableProxy(first); | 3317 VariableProxy* first_proxy = factory()->NewVariableProxy(first); |
3318 Expression* const1 = factory()->NewSmiLiteral(1, RelocInfo::kNoPosition); | 3318 Expression* const1 = factory()->NewSmiLiteral(1, RelocInfo::kNoPosition); |
3319 Assignment* assignment = factory()->NewAssignment( | 3319 Assignment* assignment = factory()->NewAssignment( |
3320 Token::ASSIGN, first_proxy, const1, RelocInfo::kNoPosition); | 3320 Token::ASSIGN, first_proxy, const1, RelocInfo::kNoPosition); |
3321 Statement* assignment_statement = | 3321 Statement* assignment_statement = |
3322 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); | 3322 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); |
3323 outer_block->AddStatement(assignment_statement, zone()); | 3323 outer_block->AddStatement(assignment_statement, zone()); |
3324 } | 3324 } |
3325 | 3325 |
3326 // make statement: undefined; | 3326 // make statement: undefined; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3386 Assignment* assignment = factory()->NewAssignment( | 3386 Assignment* assignment = factory()->NewAssignment( |
3387 Token::ASSIGN, first_proxy, const0, RelocInfo::kNoPosition); | 3387 Token::ASSIGN, first_proxy, const0, RelocInfo::kNoPosition); |
3388 clear_first = | 3388 clear_first = |
3389 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); | 3389 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); |
3390 } | 3390 } |
3391 Statement* clear_first_or_next = factory()->NewIfStatement( | 3391 Statement* clear_first_or_next = factory()->NewIfStatement( |
3392 compare, clear_first, next, RelocInfo::kNoPosition); | 3392 compare, clear_first, next, RelocInfo::kNoPosition); |
3393 ignore_completion_block->AddStatement(clear_first_or_next, zone()); | 3393 ignore_completion_block->AddStatement(clear_first_or_next, zone()); |
3394 } | 3394 } |
3395 | 3395 |
3396 Variable* flag = scope_->DeclarationScope()->NewTemporary(temp_name); | 3396 Variable* flag = scope_->TempScope()->NewTemporary(temp_name); |
3397 // Make statement: flag = 1. | 3397 // Make statement: flag = 1. |
3398 { | 3398 { |
3399 VariableProxy* flag_proxy = factory()->NewVariableProxy(flag); | 3399 VariableProxy* flag_proxy = factory()->NewVariableProxy(flag); |
3400 Expression* const1 = factory()->NewSmiLiteral(1, RelocInfo::kNoPosition); | 3400 Expression* const1 = factory()->NewSmiLiteral(1, RelocInfo::kNoPosition); |
3401 Assignment* assignment = factory()->NewAssignment( | 3401 Assignment* assignment = factory()->NewAssignment( |
3402 Token::ASSIGN, flag_proxy, const1, RelocInfo::kNoPosition); | 3402 Token::ASSIGN, flag_proxy, const1, RelocInfo::kNoPosition); |
3403 Statement* assignment_statement = | 3403 Statement* assignment_statement = |
3404 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); | 3404 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); |
3405 ignore_completion_block->AddStatement(assignment_statement, zone()); | 3405 ignore_completion_block->AddStatement(assignment_statement, zone()); |
3406 } | 3406 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3572 // { | 3572 // { |
3573 // <let x' be a temporary variable> | 3573 // <let x' be a temporary variable> |
3574 // for (x' in/of e) { | 3574 // for (x' in/of e) { |
3575 // let/const/var x; | 3575 // let/const/var x; |
3576 // x = x'; | 3576 // x = x'; |
3577 // b; | 3577 // b; |
3578 // } | 3578 // } |
3579 // let x; // for TDZ | 3579 // let x; // for TDZ |
3580 // } | 3580 // } |
3581 | 3581 |
3582 Variable* temp = scope_->DeclarationScope()->NewTemporary( | 3582 Variable* temp = scope_->TempScope()->NewTemporary( |
3583 ast_value_factory()->dot_for_string()); | 3583 ast_value_factory()->dot_for_string()); |
3584 ForEachStatement* loop = | 3584 ForEachStatement* loop = |
3585 factory()->NewForEachStatement(mode, labels, stmt_pos); | 3585 factory()->NewForEachStatement(mode, labels, stmt_pos); |
3586 Target target(&this->target_stack_, loop); | 3586 Target target(&this->target_stack_, loop); |
3587 | 3587 |
3588 Expression* enumerable = ParseExpression(true, CHECK_OK); | 3588 Expression* enumerable = ParseExpression(true, CHECK_OK); |
3589 | 3589 |
3590 Expect(Token::RPAREN, CHECK_OK); | 3590 Expect(Token::RPAREN, CHECK_OK); |
3591 | 3591 |
3592 Scope* body_scope = NewScope(scope_, BLOCK_SCOPE); | 3592 Scope* body_scope = NewScope(scope_, BLOCK_SCOPE); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4005 | 4005 |
4006 if (is_generator) { | 4006 if (is_generator) { |
4007 // For generators, allocating variables in contexts is currently a win | 4007 // For generators, allocating variables in contexts is currently a win |
4008 // because it minimizes the work needed to suspend and resume an | 4008 // because it minimizes the work needed to suspend and resume an |
4009 // activation. | 4009 // activation. |
4010 scope_->ForceContextAllocation(); | 4010 scope_->ForceContextAllocation(); |
4011 | 4011 |
4012 // Calling a generator returns a generator object. That object is stored | 4012 // Calling a generator returns a generator object. That object is stored |
4013 // in a temporary variable, a definition that is used by "yield" | 4013 // in a temporary variable, a definition that is used by "yield" |
4014 // expressions. This also marks the FunctionState as a generator. | 4014 // expressions. This also marks the FunctionState as a generator. |
4015 Variable* temp = scope_->DeclarationScope()->NewTemporary( | 4015 Variable* temp = scope_->TempScope()->NewTemporary( |
4016 ast_value_factory()->dot_generator_object_string()); | 4016 ast_value_factory()->dot_generator_object_string()); |
4017 function_state.set_generator_object_variable(temp); | 4017 function_state.set_generator_object_variable(temp); |
4018 } | 4018 } |
4019 | 4019 |
4020 Expect(Token::LPAREN, CHECK_OK); | 4020 Expect(Token::LPAREN, CHECK_OK); |
4021 int start_position = scanner()->location().beg_pos; | 4021 int start_position = scanner()->location().beg_pos; |
4022 scope_->set_start_position(start_position); | 4022 scope_->set_start_position(start_position); |
4023 ParserFormalParameterParsingState parsing_state(scope); | 4023 ParserFormalParameterParsingState parsing_state(scope); |
4024 num_parameters = | 4024 num_parameters = |
4025 ParseFormalParameterList(&parsing_state, &formals_classifier, CHECK_OK); | 4025 ParseFormalParameterList(&parsing_state, &formals_classifier, CHECK_OK); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4166 | 4166 |
4167 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( | 4167 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( |
4168 function_name, ast_value_factory(), scope, body, | 4168 function_name, ast_value_factory(), scope, body, |
4169 materialized_literal_count, expected_property_count, num_parameters, | 4169 materialized_literal_count, expected_property_count, num_parameters, |
4170 duplicate_parameters, function_type, FunctionLiteral::kIsFunction, | 4170 duplicate_parameters, function_type, FunctionLiteral::kIsFunction, |
4171 eager_compile_hint, kind, pos); | 4171 eager_compile_hint, kind, pos); |
4172 function_literal->set_function_token_position(function_token_pos); | 4172 function_literal->set_function_token_position(function_token_pos); |
4173 if (should_be_used_once_hint) | 4173 if (should_be_used_once_hint) |
4174 function_literal->set_should_be_used_once_hint(); | 4174 function_literal->set_should_be_used_once_hint(); |
4175 | 4175 |
4176 if (scope->has_rest_parameter()) { | |
4177 // TODO(caitp): enable optimization of functions with rest params | |
4178 function_literal->set_dont_optimize_reason(kRestParameter); | |
4179 } | |
4180 | |
4181 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); | 4176 if (fni_ != NULL && should_infer_name) fni_->AddFunction(function_literal); |
4182 return function_literal; | 4177 return function_literal; |
4183 } | 4178 } |
4184 | 4179 |
4185 | 4180 |
4186 void Parser::SkipLazyFunctionBody(int* materialized_literal_count, | 4181 void Parser::SkipLazyFunctionBody(int* materialized_literal_count, |
4187 int* expected_property_count, bool* ok, | 4182 int* expected_property_count, bool* ok, |
4188 Scanner::BookmarkScope* bookmark) { | 4183 Scanner::BookmarkScope* bookmark) { |
4189 DCHECK_IMPLIES(bookmark, bookmark->HasBeenSet()); | 4184 DCHECK_IMPLIES(bookmark, bookmark->HasBeenSet()); |
4190 if (produce_cached_parse_data()) CHECK(log_); | 4185 if (produce_cached_parse_data()) CHECK(log_); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4302 condition, factory()->NewExpressionStatement(throw_type_error, | 4297 condition, factory()->NewExpressionStatement(throw_type_error, |
4303 RelocInfo::kNoPosition), | 4298 RelocInfo::kNoPosition), |
4304 factory()->NewEmptyStatement(RelocInfo::kNoPosition), | 4299 factory()->NewEmptyStatement(RelocInfo::kNoPosition), |
4305 RelocInfo::kNoPosition); | 4300 RelocInfo::kNoPosition); |
4306 return if_statement; | 4301 return if_statement; |
4307 } | 4302 } |
4308 | 4303 |
4309 | 4304 |
4310 bool Parser::IsSimpleParameterList( | 4305 bool Parser::IsSimpleParameterList( |
4311 const ParserFormalParameterParsingState& formal_parameters) { | 4306 const ParserFormalParameterParsingState& formal_parameters) { |
| 4307 if (formal_parameters.has_rest) return false; |
4312 for (auto parameter : formal_parameters.params) { | 4308 for (auto parameter : formal_parameters.params) { |
4313 if (parameter.pattern != nullptr) return false; | 4309 if (parameter.pattern != nullptr) return false; |
4314 } | 4310 } |
4315 return true; | 4311 return true; |
4316 } | 4312 } |
4317 | 4313 |
4318 | 4314 |
4319 Block* Parser::BuildParameterInitializationBlock( | 4315 Block* Parser::BuildParameterInitializationBlock( |
4320 const ParserFormalParameterParsingState& formal_parameters, bool* ok) { | 4316 const ParserFormalParameterParsingState& formal_parameters, bool* ok) { |
4321 DCHECK(!IsSimpleParameterList(formal_parameters)); | 4317 DCHECK(!IsSimpleParameterList(formal_parameters)); |
(...skipping 12 matching lines...) Expand all Loading... |
4334 descriptor.needs_init = true; | 4330 descriptor.needs_init = true; |
4335 descriptor.declaration_pos = parameter.pattern->position(); | 4331 descriptor.declaration_pos = parameter.pattern->position(); |
4336 descriptor.initialization_pos = parameter.pattern->position(); | 4332 descriptor.initialization_pos = parameter.pattern->position(); |
4337 descriptor.init_op = Token::INIT_LET; | 4333 descriptor.init_op = Token::INIT_LET; |
4338 DeclarationParsingResult::Declaration decl( | 4334 DeclarationParsingResult::Declaration decl( |
4339 parameter.pattern, parameter.pattern->position(), | 4335 parameter.pattern, parameter.pattern->position(), |
4340 factory()->NewVariableProxy(parameter.var)); | 4336 factory()->NewVariableProxy(parameter.var)); |
4341 PatternRewriter::DeclareAndInitializeVariables(init_block, &descriptor, | 4337 PatternRewriter::DeclareAndInitializeVariables(init_block, &descriptor, |
4342 &decl, nullptr, CHECK_OK); | 4338 &decl, nullptr, CHECK_OK); |
4343 } | 4339 } |
| 4340 if (formal_parameters.has_rest) { |
| 4341 auto rest_parameter = formal_parameters.params.last(); |
| 4342 int rest_index = formal_parameters.params.length() - 1; |
| 4343 DCHECK_NULL(rest_parameter.pattern); |
| 4344 |
| 4345 // DESUGAR: |
| 4346 // let <rest_params> = []; |
| 4347 // for (int i = <rest_index>; i < <arguments.length>; ++i) { |
| 4348 // %AddElement(<rest_params>, <rest_params.length>, arguments[i++]); |
| 4349 // } |
| 4350 VariableProxy* proxy = factory()->NewVariableProxy(rest_parameter.var); |
| 4351 Declaration* declaration = factory()->NewVariableDeclaration( |
| 4352 proxy, VAR, scope_, RelocInfo::kNoPosition); |
| 4353 Variable* var = this->Declare(declaration, DeclarationDescriptor::PARAMETER, |
| 4354 false, CHECK_OK); |
| 4355 proxy = factory()->NewVariableProxy(var); |
| 4356 |
| 4357 // TODO(@caitp): use an array literal to avoid escaping the object and |
| 4358 // needing 2 runtime functions which do the same thing. |
| 4359 auto empty_values = new (zone()) ZoneList<Expression*>(0, zone()); |
| 4360 Expression* empty_array = factory()->NewCallRuntime( |
| 4361 is_strong(language_mode()) |
| 4362 ? ast_value_factory()->strong_empty_array_string() |
| 4363 : ast_value_factory()->empty_array_string(), |
| 4364 nullptr, empty_values, RelocInfo::kNoPosition); |
| 4365 |
| 4366 Assignment* init_array = factory()->NewAssignment( |
| 4367 Token::INIT_VAR, proxy, empty_array, RelocInfo::kNoPosition); |
| 4368 |
| 4369 auto loop = factory()->NewForStatement(NULL, RelocInfo::kNoPosition); |
| 4370 |
| 4371 // argument_index = rest_index |
| 4372 Variable* argument_index = |
| 4373 scope_->NewTemporary(ast_value_factory()->dot_string()); |
| 4374 auto init = factory()->NewExpressionStatement( |
| 4375 factory()->NewAssignment( |
| 4376 Token::INIT_VAR, factory()->NewVariableProxy(argument_index), |
| 4377 factory()->NewSmiLiteral(rest_index, RelocInfo::kNoPosition), |
| 4378 RelocInfo::kNoPosition), |
| 4379 RelocInfo::kNoPosition); |
| 4380 |
| 4381 auto arguments_length = Runtime::FunctionForId(Runtime::kArgumentsLength); |
| 4382 auto empty_arguments = new (zone()) ZoneList<Expression*>(0, zone()); |
| 4383 |
| 4384 // argument_index < %_ArgumentsLength() |
| 4385 auto cond = factory()->NewCompareOperation( |
| 4386 Token::LT, factory()->NewVariableProxy(argument_index), |
| 4387 factory()->NewCallRuntime(ast_value_factory()->empty_string(), |
| 4388 arguments_length, empty_arguments, |
| 4389 RelocInfo::kNoPosition), |
| 4390 RelocInfo::kNoPosition); |
| 4391 |
| 4392 // ++argument_index |
| 4393 auto next = factory()->NewExpressionStatement( |
| 4394 factory()->NewCountOperation( |
| 4395 Token::INC, true, factory()->NewVariableProxy(argument_index), |
| 4396 RelocInfo::kNoPosition), |
| 4397 RelocInfo::kNoPosition); |
| 4398 |
| 4399 auto arguments = Runtime::FunctionForId(Runtime::kArguments); |
| 4400 // %_Arguments(<argument_index>) |
| 4401 auto arguments_args = new (zone()) ZoneList<Expression*>(1, zone()); |
| 4402 arguments_args->Add(factory()->NewVariableProxy(argument_index), zone()); |
| 4403 |
| 4404 // %AddElement( |
| 4405 // <restParam>, <restParam.length>, %_Arguments(<argument_index>)); |
| 4406 auto add_element = Runtime::FunctionForId(Runtime::kAddElement); |
| 4407 auto add_element_args = new (zone()) ZoneList<Expression*>(3, zone()); |
| 4408 add_element_args->Add(factory()->NewVariableProxy(var), zone()); |
| 4409 add_element_args->Add( |
| 4410 factory()->NewProperty( |
| 4411 factory()->NewVariableProxy(var), |
| 4412 factory()->NewStringLiteral(ast_value_factory()->length_string(), |
| 4413 RelocInfo::kNoPosition), |
| 4414 RelocInfo::kNoPosition), |
| 4415 zone()); |
| 4416 add_element_args->Add(factory()->NewCallRuntime( |
| 4417 ast_value_factory()->empty_string(), arguments, |
| 4418 arguments_args, RelocInfo::kNoPosition), |
| 4419 zone()); |
| 4420 |
| 4421 auto body = factory()->NewExpressionStatement( |
| 4422 factory()->NewCallRuntime(ast_value_factory()->empty_string(), |
| 4423 add_element, add_element_args, |
| 4424 RelocInfo::kNoPosition), |
| 4425 RelocInfo::kNoPosition); |
| 4426 |
| 4427 loop->Initialize(init, cond, next, body); |
| 4428 init_block->AddStatement( |
| 4429 factory()->NewExpressionStatement(init_array, RelocInfo::kNoPosition), |
| 4430 zone()); |
| 4431 init_block->AddStatement(loop, zone()); |
| 4432 } |
4344 return init_block; | 4433 return init_block; |
4345 } | 4434 } |
4346 | 4435 |
4347 | 4436 |
4348 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( | 4437 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( |
4349 const AstRawString* function_name, int pos, | 4438 const AstRawString* function_name, int pos, |
4350 const ParserFormalParameterParsingState& formal_parameters, Variable* fvar, | 4439 const ParserFormalParameterParsingState& formal_parameters, Variable* fvar, |
4351 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { | 4440 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { |
4352 bool is_simple_parameter_list = IsSimpleParameterList(formal_parameters); | 4441 bool is_simple_parameter_list = IsSimpleParameterList(formal_parameters); |
4353 | 4442 |
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5957 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 6046 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
5958 } else { | 6047 } else { |
5959 if (function->IsProperty()) { | 6048 if (function->IsProperty()) { |
5960 // Method calls | 6049 // Method calls |
5961 if (function->AsProperty()->IsSuperAccess()) { | 6050 if (function->AsProperty()->IsSuperAccess()) { |
5962 Expression* home = | 6051 Expression* home = |
5963 ThisExpression(scope_, factory(), RelocInfo::kNoPosition); | 6052 ThisExpression(scope_, factory(), RelocInfo::kNoPosition); |
5964 args->InsertAt(0, function, zone()); | 6053 args->InsertAt(0, function, zone()); |
5965 args->InsertAt(1, home, zone()); | 6054 args->InsertAt(1, home, zone()); |
5966 } else { | 6055 } else { |
5967 Variable* temp = | 6056 Variable* temp = scope_->TempScope()->NewTemporary( |
5968 scope_->NewTemporary(ast_value_factory()->empty_string()); | 6057 ast_value_factory()->empty_string()); |
5969 VariableProxy* obj = factory()->NewVariableProxy(temp); | 6058 VariableProxy* obj = factory()->NewVariableProxy(temp); |
5970 Assignment* assign_obj = factory()->NewAssignment( | 6059 Assignment* assign_obj = factory()->NewAssignment( |
5971 Token::ASSIGN, obj, function->AsProperty()->obj(), | 6060 Token::ASSIGN, obj, function->AsProperty()->obj(), |
5972 RelocInfo::kNoPosition); | 6061 RelocInfo::kNoPosition); |
5973 function = factory()->NewProperty( | 6062 function = factory()->NewProperty( |
5974 assign_obj, function->AsProperty()->key(), RelocInfo::kNoPosition); | 6063 assign_obj, function->AsProperty()->key(), RelocInfo::kNoPosition); |
5975 args->InsertAt(0, function, zone()); | 6064 args->InsertAt(0, function, zone()); |
5976 obj = factory()->NewVariableProxy(temp); | 6065 obj = factory()->NewVariableProxy(temp); |
5977 args->InsertAt(1, obj, zone()); | 6066 args->InsertAt(1, obj, zone()); |
5978 } | 6067 } |
(...skipping 12 matching lines...) Expand all Loading... |
5991 Expression* Parser::SpreadCallNew(Expression* function, | 6080 Expression* Parser::SpreadCallNew(Expression* function, |
5992 ZoneList<v8::internal::Expression*>* args, | 6081 ZoneList<v8::internal::Expression*>* args, |
5993 int pos) { | 6082 int pos) { |
5994 args->InsertAt(0, function, zone()); | 6083 args->InsertAt(0, function, zone()); |
5995 | 6084 |
5996 return factory()->NewCallRuntime( | 6085 return factory()->NewCallRuntime( |
5997 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 6086 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
5998 } | 6087 } |
5999 } // namespace internal | 6088 } // namespace internal |
6000 } // namespace v8 | 6089 } // namespace v8 |
OLD | NEW |