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/parser.h" | 5 #include "src/parser.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 4347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4358 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), | 4358 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition), |
4359 RelocInfo::kNoPosition); | 4359 RelocInfo::kNoPosition); |
4360 initial_value = factory()->NewConditional( | 4360 initial_value = factory()->NewConditional( |
4361 condition, parameter.initializer, initial_value, | 4361 condition, parameter.initializer, initial_value, |
4362 RelocInfo::kNoPosition); | 4362 RelocInfo::kNoPosition); |
4363 descriptor.initialization_pos = parameter.initializer->position(); | 4363 descriptor.initialization_pos = parameter.initializer->position(); |
4364 } | 4364 } |
4365 | 4365 |
4366 Scope* param_scope = scope_; | 4366 Scope* param_scope = scope_; |
4367 Block* param_block = init_block; | 4367 Block* param_block = init_block; |
4368 if (parameter.initializer != nullptr && scope_->calls_sloppy_eval()) { | 4368 if (!parameter.is_simple() && scope_->calls_sloppy_eval()) { |
4369 param_scope = NewScope(scope_, BLOCK_SCOPE); | 4369 param_scope = NewScope(scope_, BLOCK_SCOPE); |
4370 param_scope->set_is_declaration_scope(); | 4370 param_scope->set_is_declaration_scope(); |
4371 param_scope->set_start_position(parameter.pattern->position()); | 4371 param_scope->set_start_position(parameter.pattern->position()); |
4372 param_scope->set_end_position(RelocInfo::kNoPosition); | 4372 param_scope->set_end_position(RelocInfo::kNoPosition); |
4373 param_scope->RecordEvalCall(); | 4373 param_scope->RecordEvalCall(); |
4374 param_block = factory()->NewBlock(NULL, 8, true, RelocInfo::kNoPosition); | 4374 param_block = factory()->NewBlock(NULL, 8, true, RelocInfo::kNoPosition); |
4375 param_block->set_scope(param_scope); | 4375 param_block->set_scope(param_scope); |
4376 descriptor.hoist_scope = scope_; | 4376 descriptor.hoist_scope = scope_; |
4377 } | 4377 } |
4378 | 4378 |
4379 { | 4379 { |
4380 BlockState block_state(&scope_, param_scope); | 4380 BlockState block_state(&scope_, param_scope); |
4381 DeclarationParsingResult::Declaration decl( | 4381 DeclarationParsingResult::Declaration decl( |
4382 parameter.pattern, parameter.pattern->position(), initial_value); | 4382 parameter.pattern, parameter.pattern->position(), initial_value); |
4383 PatternRewriter::DeclareAndInitializeVariables(param_block, &descriptor, | 4383 PatternRewriter::DeclareAndInitializeVariables(param_block, &descriptor, |
4384 &decl, nullptr, CHECK_OK); | 4384 &decl, nullptr, CHECK_OK); |
4385 } | 4385 } |
4386 | 4386 |
4387 if (parameter.initializer != nullptr && scope_->calls_sloppy_eval()) { | 4387 if (!parameter.is_simple() && scope_->calls_sloppy_eval()) { |
4388 param_scope = param_scope->FinalizeBlockScope(); | 4388 param_scope = param_scope->FinalizeBlockScope(); |
4389 if (param_scope != nullptr) { | 4389 if (param_scope != nullptr) { |
4390 CheckConflictingVarDeclarations(param_scope, CHECK_OK); | 4390 CheckConflictingVarDeclarations(param_scope, CHECK_OK); |
Dan Ehrenberg
2015/08/25 20:18:12
Not new in this patch, but I'm wondering why we ch
rossberg
2015/08/25 21:58:40
Indeed, I did this with do-expressions in mind. Se
| |
4391 } | 4391 } |
4392 init_block->AddStatement(param_block, zone()); | 4392 init_block->AddStatement(param_block, zone()); |
4393 } | 4393 } |
4394 } | 4394 } |
4395 return init_block; | 4395 return init_block; |
4396 } | 4396 } |
4397 | 4397 |
4398 | 4398 |
4399 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( | 4399 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( |
4400 const AstRawString* function_name, int pos, | 4400 const AstRawString* function_name, int pos, |
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6073 Expression* Parser::SpreadCallNew(Expression* function, | 6073 Expression* Parser::SpreadCallNew(Expression* function, |
6074 ZoneList<v8::internal::Expression*>* args, | 6074 ZoneList<v8::internal::Expression*>* args, |
6075 int pos) { | 6075 int pos) { |
6076 args->InsertAt(0, function, zone()); | 6076 args->InsertAt(0, function, zone()); |
6077 | 6077 |
6078 return factory()->NewCallRuntime( | 6078 return factory()->NewCallRuntime( |
6079 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 6079 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
6080 } | 6080 } |
6081 } // namespace internal | 6081 } // namespace internal |
6082 } // namespace v8 | 6082 } // namespace v8 |
OLD | NEW |