Index: src/variables.h |
diff --git a/src/variables.h b/src/variables.h |
index de7f39045af934d8a7d13320f58cbc8cb88588a2..739090a884c35f5d097517ccb4fc8a3dd13938e2 100644 |
--- a/src/variables.h |
+++ b/src/variables.h |
@@ -16,6 +16,8 @@ namespace internal { |
// they are maintained by scopes, and referred to from VariableProxies and Slots |
// after binding and variable allocation. |
+class ClassVariable; |
+ |
class Variable: public ZoneObject { |
public: |
enum Kind { NORMAL, FUNCTION, CLASS, THIS, NEW_TARGET, ARGUMENTS }; |
@@ -51,6 +53,8 @@ class Variable: public ZoneObject { |
InitializationFlag initialization_flag, |
MaybeAssignedFlag maybe_assigned_flag = kNotAssigned); |
+ virtual ~Variable() {} |
+ |
// Printing support |
static const char* Mode2String(VariableMode mode); |
@@ -102,6 +106,11 @@ class Variable: public ZoneObject { |
bool is_new_target() const { return kind_ == NEW_TARGET; } |
bool is_arguments() const { return kind_ == ARGUMENTS; } |
+ ClassVariable* AsClassVariable() { |
+ DCHECK(is_class()); |
+ return reinterpret_cast<ClassVariable*>(this); |
+ } |
+ |
// True if the variable is named eval and not known to be shadowed. |
bool is_possibly_eval(Isolate* isolate) const { |
return IsVariable(isolate->factory()->eval_string()); |
@@ -175,7 +184,33 @@ class Variable: public ZoneObject { |
MaybeAssignedFlag maybe_assigned_; |
}; |
+class ClassVariable : public Variable { |
+ public: |
+ ClassVariable(Scope* scope, const AstRawString* name, VariableMode mode, |
+ Kind kind, InitializationFlag initialization_flag, |
+ MaybeAssignedFlag maybe_assigned_flag = kNotAssigned, |
+ int declaration_group_start = -1) |
+ : Variable(scope, name, mode, kind, initialization_flag, |
+ maybe_assigned_flag), |
+ declaration_group_start_(declaration_group_start), |
+ corresponding_outer_class_variable_(nullptr) {} |
+ |
+ int declaration_group_start() const { return declaration_group_start_; } |
+ |
+ ClassVariable* corresponding_outer_class_variable() const { |
+ return corresponding_outer_class_variable_; |
+ } |
+ void set_corresponding_outer_class_variable(ClassVariable* var) { |
+ corresponding_outer_class_variable_ = var; |
+ } |
+ private: |
+ // For classes we keep track of consecutive groups of delcarations. They are |
+ // needed for strong mode scoping checks. TODO(marja, rossberg): Implement |
+ // checks for functions too. |
+ int declaration_group_start_; |
+ ClassVariable* corresponding_outer_class_variable_; |
+}; |
} } // namespace v8::internal |
#endif // V8_VARIABLES_H_ |