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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = factory()->NewVariableProxy( |
135 name, NORMAL_VARIABLE, parser_->scanner()->location().beg_pos, | 135 name, NORMAL_VARIABLE, parser_->scanner()->location().beg_pos); |
136 parser_->scanner()->location().end_pos); | |
137 Declaration* declaration = factory()->NewVariableDeclaration( | 136 Declaration* declaration = factory()->NewVariableDeclaration( |
138 proxy, descriptor_->scope, descriptor_->declaration_pos); | 137 proxy, descriptor_->scope, descriptor_->declaration_pos); |
139 Variable* var = parser_->Declare( | 138 Variable* var = parser_->Declare( |
140 declaration, descriptor_->declaration_kind, descriptor_->mode, | 139 declaration, descriptor_->declaration_kind, descriptor_->mode, |
141 Variable::DefaultInitializationFlag(descriptor_->mode), ok_, | 140 Variable::DefaultInitializationFlag(descriptor_->mode), ok_, |
142 descriptor_->hoist_scope); | 141 descriptor_->hoist_scope); |
143 if (!*ok_) return; | 142 if (!*ok_) return; |
144 DCHECK_NOT_NULL(var); | 143 DCHECK_NOT_NULL(var); |
145 DCHECK(proxy->is_resolved()); | 144 DCHECK(proxy->is_resolved()); |
146 DCHECK(initializer_position_ != kNoSourcePosition); | 145 DCHECK(initializer_position_ != kNoSourcePosition); |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 NOT_A_PATTERN(TryFinallyStatement) | 687 NOT_A_PATTERN(TryFinallyStatement) |
689 NOT_A_PATTERN(UnaryOperation) | 688 NOT_A_PATTERN(UnaryOperation) |
690 NOT_A_PATTERN(VariableDeclaration) | 689 NOT_A_PATTERN(VariableDeclaration) |
691 NOT_A_PATTERN(WhileStatement) | 690 NOT_A_PATTERN(WhileStatement) |
692 NOT_A_PATTERN(WithStatement) | 691 NOT_A_PATTERN(WithStatement) |
693 NOT_A_PATTERN(Yield) | 692 NOT_A_PATTERN(Yield) |
694 | 693 |
695 #undef NOT_A_PATTERN | 694 #undef NOT_A_PATTERN |
696 } // namespace internal | 695 } // namespace internal |
697 } // namespace v8 | 696 } // namespace v8 |
OLD | NEW |