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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(declaration, descriptor_->declaration_kind, |
57 descriptor_->mode != VAR, ok_); | 57 descriptor_->mode != VAR, ok_, |
| 58 descriptor_->hoist_scope); |
58 if (!*ok_) return; | 59 if (!*ok_) return; |
59 DCHECK_NOT_NULL(var); | 60 DCHECK_NOT_NULL(var); |
60 DCHECK(!proxy->is_resolved() || proxy->var() == var); | 61 DCHECK(!proxy->is_resolved() || proxy->var() == var); |
61 var->set_initializer_position(initializer_position_); | 62 var->set_initializer_position(initializer_position_); |
62 | 63 |
63 DCHECK(initializer_position_ != RelocInfo::kNoPosition); | 64 DCHECK(initializer_position_ != RelocInfo::kNoPosition); |
64 | 65 |
65 if (descriptor_->declaration_scope->num_var_or_const() > | 66 if (descriptor_->declaration_scope->num_var_or_const() > |
66 kMaxNumFunctionLocals) { | 67 kMaxNumFunctionLocals) { |
67 parser->ReportMessage(MessageTemplate::kTooManyVariables); | 68 parser->ReportMessage(MessageTemplate::kTooManyVariables); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 NOT_A_PATTERN(TryFinallyStatement) | 415 NOT_A_PATTERN(TryFinallyStatement) |
415 NOT_A_PATTERN(UnaryOperation) | 416 NOT_A_PATTERN(UnaryOperation) |
416 NOT_A_PATTERN(VariableDeclaration) | 417 NOT_A_PATTERN(VariableDeclaration) |
417 NOT_A_PATTERN(WhileStatement) | 418 NOT_A_PATTERN(WhileStatement) |
418 NOT_A_PATTERN(WithStatement) | 419 NOT_A_PATTERN(WithStatement) |
419 NOT_A_PATTERN(Yield) | 420 NOT_A_PATTERN(Yield) |
420 | 421 |
421 #undef NOT_A_PATTERN | 422 #undef NOT_A_PATTERN |
422 } // namespace internal | 423 } // namespace internal |
423 } // namespace v8 | 424 } // namespace v8 |
OLD | NEW |