Index: src/ast/scopes.cc |
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
index 21c9e2e373b5408c58fa61b646cbe1d39c3a1e20..c2b05b7c040ca6ed11f700d952a10947fb4e893c 100644 |
--- a/src/ast/scopes.cc |
+++ b/src/ast/scopes.cc |
@@ -575,11 +575,24 @@ Variable* Scope::NewTemporary(const AstRawString* name) { |
TEMPORARY, |
Variable::NORMAL, |
kCreatedInitialized); |
- scope->temps_.Add(var, zone()); |
+ scope->AddTemporary(var); |
return var; |
} |
+bool Scope::RemoveTemporary(Variable* var) { |
+ // Most likely (always?) any temporary variable we want to remove |
+ // was just added before, so we search backwards. |
+ for (int i = temps_.length(); i-- > 0;) { |
+ if (temps_[i] == var) { |
+ temps_.Remove(i); |
+ return true; |
+ } |
+ } |
+ return false; |
+} |
+ |
+ |
void Scope::AddDeclaration(Declaration* declaration) { |
decls_.Add(declaration, zone()); |
} |