Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: src/ast/scopes.h

Issue 2264053003: Keep track of the addition order of variables explicitly. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.h
diff --git a/src/ast/scopes.h b/src/ast/scopes.h
index ea478f69b1c269c1ac438f10113f1923a6c6a633..5f33fa49c171151a88b904d7da0536ac12b89818 100644
--- a/src/ast/scopes.h
+++ b/src/ast/scopes.h
@@ -23,7 +23,8 @@ class VariableMap: public ZoneHashMap {
Variable* Declare(Zone* zone, Scope* scope, const AstRawString* name,
VariableMode mode, Variable::Kind kind,
InitializationFlag initialization_flag,
- MaybeAssignedFlag maybe_assigned_flag = kNotAssigned);
+ MaybeAssignedFlag maybe_assigned_flag = kNotAssigned,
+ bool* added = nullptr);
Variable* Lookup(const AstRawString* name);
};
@@ -447,6 +448,17 @@ class Scope: public ZoneObject {
}
private:
+ Variable* Declare(Zone* zone, Scope* scope, const AstRawString* name,
+ VariableMode mode, Variable::Kind kind,
+ InitializationFlag initialization_flag,
+ MaybeAssignedFlag maybe_assigned_flag = kNotAssigned) {
+ bool added;
+ Variable* var =
+ variables_.Declare(zone, scope, name, mode, kind, initialization_flag,
+ maybe_assigned_flag, &added);
+ if (added) ordered_variables_.Add(var, zone);
+ return var;
+ }
Zone* zone_;
// Scope tree.
@@ -460,6 +472,10 @@ class Scope: public ZoneObject {
// variables may be implicitly 'declared' by being used (possibly in
// an inner scope) with no intervening with statements or eval calls.
VariableMap variables_;
+ // In case of non-scopeinfo-backed scopes, this contains the variables of the
+ // map above in order of addition.
+ // TODO(verwaest): Thread through Variable.
+ ZoneList<Variable*> ordered_variables_;
// Variables that must be looked up dynamically.
DynamicScopePart* dynamics_;
// Unresolved variables referred to from this scope. The proxies themselves
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698