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/objects-inl.h" | 7 #include "src/objects-inl.h" |
8 #include "src/parsing/parameter-initializer-rewriter.h" | 8 #include "src/parsing/parameter-initializer-rewriter.h" |
9 #include "src/parsing/parser.h" | 9 #include "src/parsing/parser.h" |
10 | 10 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 if (names_) { | 170 if (names_) { |
171 names_->Add(name, zone()); | 171 names_->Add(name, zone()); |
172 } | 172 } |
173 | 173 |
174 Scope* var_init_scope = descriptor_->scope; | 174 Scope* var_init_scope = descriptor_->scope; |
175 MarkTopLevelVariableAsAssigned(var_init_scope, proxy); | 175 MarkTopLevelVariableAsAssigned(var_init_scope, proxy); |
176 | 176 |
177 // If there's no initializer, we're done. | 177 // If there's no initializer, we're done. |
178 if (value == nullptr) return; | 178 if (value == nullptr) return; |
179 | 179 |
180 MarkLoopVariableAsAssigned(var_init_scope, proxy->var()); | |
181 | |
182 // A declaration of the form: | 180 // A declaration of the form: |
183 // | 181 // |
184 // var v = x; | 182 // var v = x; |
185 // | 183 // |
186 // is syntactic sugar for: | 184 // is syntactic sugar for: |
187 // | 185 // |
188 // var v; v = x; | 186 // var v; v = x; |
189 // | 187 // |
190 // In particular, we need to re-lookup 'v' as it may be a different | 188 // In particular, we need to re-lookup 'v' as it may be a different |
191 // 'v' than the 'v' in the declaration (e.g., if we are inside a | 189 // 'v' than the 'v' in the declaration (e.g., if we are inside a |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 NOT_A_PATTERN(TryFinallyStatement) | 758 NOT_A_PATTERN(TryFinallyStatement) |
761 NOT_A_PATTERN(UnaryOperation) | 759 NOT_A_PATTERN(UnaryOperation) |
762 NOT_A_PATTERN(VariableDeclaration) | 760 NOT_A_PATTERN(VariableDeclaration) |
763 NOT_A_PATTERN(WhileStatement) | 761 NOT_A_PATTERN(WhileStatement) |
764 NOT_A_PATTERN(WithStatement) | 762 NOT_A_PATTERN(WithStatement) |
765 NOT_A_PATTERN(Yield) | 763 NOT_A_PATTERN(Yield) |
766 | 764 |
767 #undef NOT_A_PATTERN | 765 #undef NOT_A_PATTERN |
768 } // namespace internal | 766 } // namespace internal |
769 } // namespace v8 | 767 } // namespace v8 |
OLD | NEW |