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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 // Declare variable. | 125 // Declare variable. |
126 // Note that we *always* must treat the initial value via a separate init | 126 // Note that we *always* must treat the initial value via a separate init |
127 // assignment for variables and constants because the value must be assigned | 127 // assignment for variables and constants because the value must be assigned |
128 // when the variable is encountered in the source. But the variable/constant | 128 // when the variable is encountered in the source. But the variable/constant |
129 // is declared (and set to 'undefined') upon entering the function within | 129 // is declared (and set to 'undefined') upon entering the function within |
130 // which the variable or constant is declared. Only function variables have | 130 // which the variable or constant is declared. Only function variables have |
131 // an initial value in the declaration (because they are initialized upon | 131 // an initial value in the declaration (because they are initialized upon |
132 // entering the function). | 132 // entering the function). |
133 const AstRawString* name = pattern->raw_name(); | 133 const AstRawString* name = pattern->raw_name(); |
134 VariableProxy* proxy = factory()->NewVariableProxy( | 134 VariableProxy* proxy = |
135 name, NORMAL_VARIABLE, parser_->scanner()->location().beg_pos); | 135 factory()->NewVariableProxy(name, NORMAL_VARIABLE, pattern->position()); |
136 Declaration* declaration = factory()->NewVariableDeclaration( | 136 Declaration* declaration = factory()->NewVariableDeclaration( |
137 proxy, descriptor_->scope, descriptor_->declaration_pos); | 137 proxy, descriptor_->scope, descriptor_->declaration_pos); |
138 Variable* var = parser_->Declare( | 138 Variable* var = parser_->Declare( |
139 declaration, descriptor_->declaration_kind, descriptor_->mode, | 139 declaration, descriptor_->declaration_kind, descriptor_->mode, |
140 Variable::DefaultInitializationFlag(descriptor_->mode), ok_, | 140 Variable::DefaultInitializationFlag(descriptor_->mode), ok_, |
141 descriptor_->hoist_scope); | 141 descriptor_->hoist_scope); |
142 if (!*ok_) return; | 142 if (!*ok_) return; |
143 DCHECK_NOT_NULL(var); | 143 DCHECK_NOT_NULL(var); |
144 DCHECK(proxy->is_resolved()); | 144 DCHECK(proxy->is_resolved()); |
145 DCHECK(initializer_position_ != kNoSourcePosition); | 145 DCHECK(initializer_position_ != kNoSourcePosition); |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 NOT_A_PATTERN(TryFinallyStatement) | 687 NOT_A_PATTERN(TryFinallyStatement) |
688 NOT_A_PATTERN(UnaryOperation) | 688 NOT_A_PATTERN(UnaryOperation) |
689 NOT_A_PATTERN(VariableDeclaration) | 689 NOT_A_PATTERN(VariableDeclaration) |
690 NOT_A_PATTERN(WhileStatement) | 690 NOT_A_PATTERN(WhileStatement) |
691 NOT_A_PATTERN(WithStatement) | 691 NOT_A_PATTERN(WithStatement) |
692 NOT_A_PATTERN(Yield) | 692 NOT_A_PATTERN(Yield) |
693 | 693 |
694 #undef NOT_A_PATTERN | 694 #undef NOT_A_PATTERN |
695 } // namespace internal | 695 } // namespace internal |
696 } // namespace v8 | 696 } // namespace v8 |
OLD | NEW |