| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/ast.h" | 5 #include "src/ast.h" |
| 6 #include "src/messages.h" | 6 #include "src/messages.h" |
| 7 #include "src/parser.h" | 7 #include "src/parser.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // surrounding 'with' statements). | 46 // surrounding 'with' statements). |
| 47 // For let/const declarations in harmony mode, we can also immediately | 47 // For let/const declarations in harmony mode, we can also immediately |
| 48 // pre-resolve the proxy because it resides in the same scope as the | 48 // pre-resolve the proxy because it resides in the same scope as the |
| 49 // declaration. | 49 // declaration. |
| 50 Parser* parser = descriptor_->parser; | 50 Parser* parser = descriptor_->parser; |
| 51 const AstRawString* name = pattern->raw_name(); | 51 const AstRawString* name = pattern->raw_name(); |
| 52 VariableProxy* proxy = parser->NewUnresolved(name, descriptor_->mode); | 52 VariableProxy* proxy = parser->NewUnresolved(name, descriptor_->mode); |
| 53 Declaration* declaration = factory()->NewVariableDeclaration( | 53 Declaration* declaration = factory()->NewVariableDeclaration( |
| 54 proxy, descriptor_->mode, descriptor_->scope, | 54 proxy, descriptor_->mode, descriptor_->scope, |
| 55 descriptor_->declaration_pos); | 55 descriptor_->declaration_pos); |
| 56 Variable* var = parser->Declare(declaration, descriptor_->declaration_kind, | 56 Variable* var = parser->Declare( |
| 57 descriptor_->mode != VAR, ok_, | 57 declaration, descriptor_->declaration_kind, |
| 58 descriptor_->hoist_scope); | 58 descriptor_->declaration_kind == DeclarationDescriptor::PARAMETER || |
| 59 descriptor_->mode != VAR, |
| 60 ok_, descriptor_->hoist_scope); |
| 59 if (!*ok_) return; | 61 if (!*ok_) return; |
| 60 DCHECK_NOT_NULL(var); | 62 DCHECK_NOT_NULL(var); |
| 61 DCHECK(!proxy->is_resolved() || proxy->var() == var); | 63 DCHECK(!proxy->is_resolved() || proxy->var() == var); |
| 62 var->set_initializer_position(initializer_position_); | 64 var->set_initializer_position(initializer_position_); |
| 63 | 65 |
| 64 DCHECK(initializer_position_ != RelocInfo::kNoPosition); | 66 DCHECK(initializer_position_ != RelocInfo::kNoPosition); |
| 65 | 67 |
| 66 if (descriptor_->declaration_scope->num_var_or_const() > | 68 if (descriptor_->declaration_scope->num_var_or_const() > |
| 67 kMaxNumFunctionLocals) { | 69 kMaxNumFunctionLocals) { |
| 68 parser->ReportMessage(MessageTemplate::kTooManyVariables); | 70 parser->ReportMessage(MessageTemplate::kTooManyVariables); |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 NOT_A_PATTERN(TryFinallyStatement) | 420 NOT_A_PATTERN(TryFinallyStatement) |
| 419 NOT_A_PATTERN(UnaryOperation) | 421 NOT_A_PATTERN(UnaryOperation) |
| 420 NOT_A_PATTERN(VariableDeclaration) | 422 NOT_A_PATTERN(VariableDeclaration) |
| 421 NOT_A_PATTERN(WhileStatement) | 423 NOT_A_PATTERN(WhileStatement) |
| 422 NOT_A_PATTERN(WithStatement) | 424 NOT_A_PATTERN(WithStatement) |
| 423 NOT_A_PATTERN(Yield) | 425 NOT_A_PATTERN(Yield) |
| 424 | 426 |
| 425 #undef NOT_A_PATTERN | 427 #undef NOT_A_PATTERN |
| 426 } // namespace internal | 428 } // namespace internal |
| 427 } // namespace v8 | 429 } // namespace v8 |
| OLD | NEW |