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/parsing/parameter-initializer-rewriter.h" | 5 #include "src/parsing/parameter-initializer-rewriter.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/ast-expression-visitor.h" | 8 #include "src/ast/ast-expression-visitor.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 Visit(prop->key()); | 53 Visit(prop->key()); |
54 } | 54 } |
55 // No need to visit the values, since all values are functions with | 55 // No need to visit the values, since all values are functions with |
56 // the class scope on their scope chain. | 56 // the class scope on their scope chain. |
57 DCHECK(prop->value()->IsFunctionLiteral()); | 57 DCHECK(prop->value()->IsFunctionLiteral()); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 void Rewriter::VisitVariableProxy(VariableProxy* proxy) { | 62 void Rewriter::VisitVariableProxy(VariableProxy* proxy) { |
63 DCHECK(!proxy->is_resolved()); | 63 if (proxy->is_resolved()) { |
64 if (old_scope_->RemoveUnresolved(proxy)) { | 64 Variable* var = proxy->var(); |
| 65 DCHECK_EQ(var->mode(), TEMPORARY); |
| 66 if (old_scope_->RemoveTemporary(var)) { |
| 67 var->set_scope(new_scope_); |
| 68 new_scope_->AddTemporary(var); |
| 69 } |
| 70 } else if (old_scope_->RemoveUnresolved(proxy)) { |
65 new_scope_->AddUnresolved(proxy); | 71 new_scope_->AddUnresolved(proxy); |
66 } | 72 } |
67 } | 73 } |
68 | 74 |
69 | 75 |
70 } // anonymous namespace | 76 } // anonymous namespace |
71 | 77 |
72 | 78 |
73 void RewriteParameterInitializerScope(uintptr_t stack_limit, | 79 void RewriteParameterInitializerScope(uintptr_t stack_limit, |
74 Expression* initializer, Scope* old_scope, | 80 Expression* initializer, Scope* old_scope, |
75 Scope* new_scope) { | 81 Scope* new_scope) { |
76 Rewriter rewriter(stack_limit, initializer, old_scope, new_scope); | 82 Rewriter rewriter(stack_limit, initializer, old_scope, new_scope); |
77 rewriter.Run(); | 83 rewriter.Run(); |
78 } | 84 } |
79 | 85 |
80 | 86 |
81 } // namespace internal | 87 } // namespace internal |
82 } // namespace v8 | 88 } // namespace v8 |
OLD | NEW |