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 <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // the class scope on their scope chain. | 83 // the class scope on their scope chain. |
84 DCHECK(prop->value()->IsFunctionLiteral()); | 84 DCHECK(prop->value()->IsFunctionLiteral()); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 | 88 |
89 void Rewriter::VisitVariableProxy(VariableProxy* proxy) { | 89 void Rewriter::VisitVariableProxy(VariableProxy* proxy) { |
90 if (proxy->is_resolved()) { | 90 if (proxy->is_resolved()) { |
91 Variable* var = proxy->var(); | 91 Variable* var = proxy->var(); |
92 if (var->mode() != TEMPORARY) return; | 92 if (var->mode() != TEMPORARY) return; |
93 // For rewriting inside the same ClosureScope (e.g., putting default | |
94 // parameter values in their own inner scope in certain cases), refrain | |
95 // from invalidly moving temporaries to a block scope. | |
96 if (var->scope()->ClosureScope() == new_scope_->ClosureScope()) return; | |
97 int index = old_scope_->RemoveTemporary(var); | 93 int index = old_scope_->RemoveTemporary(var); |
98 if (index >= 0) { | 94 if (index >= 0) { |
99 temps_.push_back(std::make_pair(var, index)); | 95 temps_.push_back(std::make_pair(var, index)); |
100 } | 96 } |
101 } else if (old_scope_->RemoveUnresolved(proxy)) { | 97 } else if (old_scope_->RemoveUnresolved(proxy)) { |
102 new_scope_->AddUnresolved(proxy); | 98 new_scope_->AddUnresolved(proxy); |
103 } | 99 } |
104 } | 100 } |
105 | 101 |
106 | 102 |
(...skipping 23 matching lines...) Expand all Loading... |
130 void RewriteParameterInitializerScope(uintptr_t stack_limit, | 126 void RewriteParameterInitializerScope(uintptr_t stack_limit, |
131 Expression* initializer, Scope* old_scope, | 127 Expression* initializer, Scope* old_scope, |
132 Scope* new_scope) { | 128 Scope* new_scope) { |
133 Rewriter rewriter(stack_limit, initializer, old_scope, new_scope); | 129 Rewriter rewriter(stack_limit, initializer, old_scope, new_scope); |
134 rewriter.Run(); | 130 rewriter.Run(); |
135 } | 131 } |
136 | 132 |
137 | 133 |
138 } // namespace internal | 134 } // namespace internal |
139 } // namespace v8 | 135 } // namespace v8 |
OLD | NEW |