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