Chromium Code Reviews| Index: src/variables.h |
| diff --git a/src/variables.h b/src/variables.h |
| index de7f39045af934d8a7d13320f58cbc8cb88588a2..6f661d7406b66b6bd50fd24928d0057006d478cf 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,35 @@ 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 class_declaration_group_start = -1) |
| + : Variable(scope, name, mode, kind, initialization_flag, |
| + maybe_assigned_flag), |
| + class_declaration_group_start_(class_declaration_group_start), |
| + corresponding_outer_class_variable_(nullptr) {} |
| + |
| + int class_declaration_group_start() const { |
|
rossberg
2015/04/23 12:20:53
Nit: since this is now in ClassVariable, the class
marja
2015/04/23 13:12:43
Done.
|
| + return class_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 class_declaration_group_start_; |
| + ClassVariable* corresponding_outer_class_variable_; |
| +}; |
| } } // namespace v8::internal |
| #endif // V8_VARIABLES_H_ |