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

Unified Diff: src/variables.h

Issue 1060913005: [strong] Stricter check for referring to other classes inside methods. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: code review (rossberg@) Created 5 years, 8 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/scopes.cc ('k') | test/mjsunit/strong/mutually-recursive-classes.js » ('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 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_
« no previous file with comments | « src/scopes.cc ('k') | test/mjsunit/strong/mutually-recursive-classes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698