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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // But for var declarations we need to do a new lookup. | 220 // But for var declarations we need to do a new lookup. |
221 if (descriptor_->mode == VAR) { | 221 if (descriptor_->mode == VAR) { |
222 proxy = var_init_scope->NewUnresolved(factory(), name); | 222 proxy = var_init_scope->NewUnresolved(factory(), name); |
223 // TODO(neis): Set is_assigned on proxy. | 223 // TODO(neis): Set is_assigned on proxy. |
224 } else { | 224 } else { |
225 DCHECK_NOT_NULL(proxy); | 225 DCHECK_NOT_NULL(proxy); |
226 DCHECK_NOT_NULL(proxy->var()); | 226 DCHECK_NOT_NULL(proxy->var()); |
227 if (var_init_scope->is_script_scope() || | 227 if (var_init_scope->is_script_scope() || |
228 var_init_scope->is_module_scope()) { | 228 var_init_scope->is_module_scope()) { |
229 // We have to pessimistically assume that top-level variables will be | 229 // We have to pessimistically assume that top-level variables will be |
230 // assigned. This is because there may be lazily parsed top-level | 230 // assigned. This is because they might be accessed by a lazily parsed |
231 // functions, which, for efficiency, we preparse without variable | 231 // top-level function, which, for efficiency, we preparse without |
232 // tracking. | 232 // variable tracking. In the case of a script (not a module), they |
| 233 // might also get accessed by another script. |
233 proxy->set_is_assigned(); | 234 proxy->set_is_assigned(); |
234 } | 235 } |
235 } | 236 } |
236 // Add break location for destructured sub-pattern. | 237 // Add break location for destructured sub-pattern. |
237 int pos = IsSubPattern() ? pattern->position() : value->position(); | 238 int pos = IsSubPattern() ? pattern->position() : value->position(); |
238 Assignment* assignment = | 239 Assignment* assignment = |
239 factory()->NewAssignment(Token::INIT, proxy, value, pos); | 240 factory()->NewAssignment(Token::INIT, proxy, value, pos); |
240 block_->statements()->Add( | 241 block_->statements()->Add( |
241 factory()->NewExpressionStatement(assignment, pos), zone()); | 242 factory()->NewExpressionStatement(assignment, pos), zone()); |
242 } | 243 } |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 NOT_A_PATTERN(TryFinallyStatement) | 744 NOT_A_PATTERN(TryFinallyStatement) |
744 NOT_A_PATTERN(UnaryOperation) | 745 NOT_A_PATTERN(UnaryOperation) |
745 NOT_A_PATTERN(VariableDeclaration) | 746 NOT_A_PATTERN(VariableDeclaration) |
746 NOT_A_PATTERN(WhileStatement) | 747 NOT_A_PATTERN(WhileStatement) |
747 NOT_A_PATTERN(WithStatement) | 748 NOT_A_PATTERN(WithStatement) |
748 NOT_A_PATTERN(Yield) | 749 NOT_A_PATTERN(Yield) |
749 | 750 |
750 #undef NOT_A_PATTERN | 751 #undef NOT_A_PATTERN |
751 } // namespace internal | 752 } // namespace internal |
752 } // namespace v8 | 753 } // namespace v8 |
OLD | NEW |