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

Unified Diff: src/variables.h

Issue 1218783005: Support for global var shortcuts in script contexts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixing builds Created 5 years, 5 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 | « src/typing.cc ('k') | src/variables.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/variables.h
diff --git a/src/variables.h b/src/variables.h
index 218eefae08e08a0cd937a14e1d158c5b878d1a0c..deebc5f80c83b5a63afd37bc63d2b896e1890c8c 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -22,33 +22,6 @@ class Variable: public ZoneObject {
public:
enum Kind { NORMAL, FUNCTION, CLASS, THIS, ARGUMENTS };
- enum Location {
- // Before and during variable allocation, a variable whose location is
- // not yet determined. After allocation, a variable looked up as a
- // property on the global object (and possibly absent). name() is the
- // variable name, index() is invalid.
- UNALLOCATED,
-
- // A slot in the parameter section on the stack. index() is the
- // parameter index, counting left-to-right. The receiver is index -1;
- // the first parameter is index 0.
- PARAMETER,
-
- // A slot in the local section on the stack. index() is the variable
- // index in the stack frame, starting at 0.
- LOCAL,
-
- // An indexed slot in a heap context. index() is the variable index in
- // the context object on the heap, starting at 0. scope() is the
- // corresponding scope.
- CONTEXT,
-
- // A named slot in a heap context. name() is the variable name in the
- // context object on the heap, with lookup starting at the current
- // context. index() is invalid.
- LOOKUP
- };
-
Variable(Scope* scope, const AstRawString* name, VariableMode mode, Kind kind,
InitializationFlag initialization_flag,
MaybeAssignedFlag maybe_assigned_flag = kNotAssigned);
@@ -86,13 +59,20 @@ class Variable: public ZoneObject {
return !is_this() && name().is_identical_to(n);
}
- bool IsUnallocated() const { return location_ == UNALLOCATED; }
- bool IsParameter() const { return location_ == PARAMETER; }
- bool IsStackLocal() const { return location_ == LOCAL; }
+ bool IsUnallocated() const {
+ return location_ == VariableLocation::UNALLOCATED;
+ }
+ bool IsParameter() const { return location_ == VariableLocation::PARAMETER; }
+ bool IsStackLocal() const { return location_ == VariableLocation::LOCAL; }
bool IsStackAllocated() const { return IsParameter() || IsStackLocal(); }
- bool IsContextSlot() const { return location_ == CONTEXT; }
- bool IsLookupSlot() const { return location_ == LOOKUP; }
+ bool IsContextSlot() const { return location_ == VariableLocation::CONTEXT; }
+ bool IsGlobalSlot() const { return location_ == VariableLocation::GLOBAL; }
+ bool IsUnallocatedOrGlobalSlot() const {
+ return IsUnallocated() || IsGlobalSlot();
+ }
+ bool IsLookupSlot() const { return location_ == VariableLocation::LOOKUP; }
bool IsGlobalObjectProperty() const;
+ bool IsStaticGlobalObjectProperty() const;
bool is_dynamic() const { return IsDynamicVariableMode(mode_); }
bool is_const_mode() const { return IsImmutableVariableMode(mode_); }
@@ -134,13 +114,13 @@ class Variable: public ZoneObject {
local_if_not_shadowed_ = local;
}
- Location location() const { return location_; }
+ VariableLocation location() const { return location_; }
int index() const { return index_; }
InitializationFlag initialization_flag() const {
return initialization_flag_;
}
- void AllocateTo(Location location, int index) {
+ void AllocateTo(VariableLocation location, int index) {
location_ = location;
index_ = index;
}
@@ -171,7 +151,7 @@ class Variable: public ZoneObject {
const AstRawString* name_;
VariableMode mode_;
Kind kind_;
- Location location_;
+ VariableLocation location_;
int index_;
int initializer_position_;
// Tracks whether the variable is bound to a VariableProxy which is in strong
« no previous file with comments | « src/typing.cc ('k') | src/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698