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

Unified Diff: runtime/vm/kernel.h

Issue 2782913003: Revert "Remove definitions from Kernel canonical names." (Closed)
Patch Set: Created 3 years, 9 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 | « pkg/kernel/lib/canonical_name.dart ('k') | runtime/vm/kernel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel.h
diff --git a/runtime/vm/kernel.h b/runtime/vm/kernel.h
index 54f1b9ab9b67b2eb59d4fe8780fc46b3ce3a6a43..65a681bf9e5f7d25ca6fcb057444bbb29dae0db4 100644
--- a/runtime/vm/kernel.h
+++ b/runtime/vm/kernel.h
@@ -118,6 +118,8 @@
M(ClassVisitor) \
M(InitializerVisitor) \
M(DartTypeVisitor) \
+ M(ClassReferenceVisitor) \
+ M(MemberReferenceVisitor) \
M(TreeVisitor) \
M(Visitor)
@@ -368,29 +370,20 @@ class CanonicalName {
String* name() { return name_; }
CanonicalName* parent() { return parent_; }
+ LinkedNode* definition() { return definition_; }
bool is_referenced() { return is_referenced_; }
void set_referenced(bool referenced) { is_referenced_ = referenced; }
+ void BindTo(LinkedNode* definition);
+ void Unbind();
CanonicalName* AddChild(String* name);
- bool IsAdministrative();
- bool IsPrivate();
-
- bool IsRoot();
- bool IsLibrary();
- bool IsClass();
- bool IsMember();
- bool IsField();
- bool IsConstructor();
- bool IsProcedure();
- bool IsMethod();
- bool IsGetter();
- bool IsSetter();
- bool IsFactory();
-
- // For a member (field, constructor, or procedure) return the canonical name
- // of the enclosing class or library.
- CanonicalName* EnclosingName();
+ Library* AsLibrary();
+ Class* AsClass();
+ Member* AsMember();
+ Field* AsField();
+ Constructor* AsConstructor();
+ Procedure* AsProcedure();
static CanonicalName* NewRoot();
@@ -400,6 +393,7 @@ class CanonicalName {
bool is_referenced_;
Ref<CanonicalName> parent_;
Ref<String> name_;
+ Ref<LinkedNode> definition_;
MallocGrowableArray<CanonicalName*> children_;
DISALLOW_COPY_AND_ASSIGN(CanonicalName);
@@ -463,9 +457,9 @@ class LinkedNode : public TreeNode {
protected:
LinkedNode() {}
+ private:
Ref<CanonicalName> canonical_name_;
- private:
friend class CanonicalName;
DISALLOW_COPY_AND_ASSIGN(LinkedNode);
@@ -539,6 +533,7 @@ class Class : public LinkedNode {
virtual void AcceptTreeVisitor(TreeVisitor* visitor);
virtual void AcceptClassVisitor(ClassVisitor* visitor) = 0;
+ virtual void AcceptReferenceVisitor(ClassReferenceVisitor* visitor) = 0;
Library* parent() { return parent_; }
String* name() { return name_; }
@@ -580,6 +575,7 @@ class NormalClass : public Class {
DEFINE_CASTING_OPERATIONS(NormalClass);
virtual void AcceptClassVisitor(ClassVisitor* visitor);
+ virtual void AcceptReferenceVisitor(ClassReferenceVisitor* visitor);
virtual void VisitChildren(Visitor* visitor);
virtual TypeParameterList& type_parameters() { return type_parameters_; }
@@ -617,6 +613,7 @@ class MixinClass : public Class {
DEFINE_CASTING_OPERATIONS(MixinClass);
virtual void AcceptClassVisitor(ClassVisitor* visitor);
+ virtual void AcceptReferenceVisitor(ClassReferenceVisitor* visitor);
virtual void VisitChildren(Visitor* visitor);
virtual TypeParameterList& type_parameters() { return type_parameters_; }
@@ -657,6 +654,7 @@ class Member : public LinkedNode {
virtual void AcceptTreeVisitor(TreeVisitor* visitor);
virtual void AcceptMemberVisitor(MemberVisitor* visitor) = 0;
+ virtual void AcceptReferenceVisitor(MemberReferenceVisitor* visitor) = 0;
TreeNode* parent() { return parent_; }
Name* name() { return name_; }
@@ -698,6 +696,7 @@ class Field : public Member {
DEFINE_CASTING_OPERATIONS(Field);
virtual void AcceptMemberVisitor(MemberVisitor* visitor);
+ virtual void AcceptReferenceVisitor(MemberReferenceVisitor* visitor);
virtual void VisitChildren(Visitor* visitor);
bool IsConst() { return (flags_ & kFlagConst) == kFlagConst; }
@@ -737,6 +736,7 @@ class Constructor : public Member {
DEFINE_CASTING_OPERATIONS(Constructor);
virtual void AcceptMemberVisitor(MemberVisitor* visitor);
+ virtual void AcceptReferenceVisitor(MemberReferenceVisitor* visitor);
virtual void VisitChildren(Visitor* visitor);
bool IsExternal() { return (flags_ & kFlagExternal) == kFlagExternal; }
@@ -786,6 +786,7 @@ class Procedure : public Member {
DEFINE_CASTING_OPERATIONS(Procedure);
virtual void AcceptMemberVisitor(MemberVisitor* visitor);
+ virtual void AcceptReferenceVisitor(MemberReferenceVisitor* visitor);
virtual void VisitChildren(Visitor* visitor);
ProcedureKind kind() { return kind_; }
@@ -859,13 +860,13 @@ class FieldInitializer : public Initializer {
virtual void AcceptInitializerVisitor(InitializerVisitor* visitor);
virtual void VisitChildren(Visitor* visitor);
- CanonicalName* field() { return field_reference_; }
+ Field* field() { return field_reference_->AsField(); }
Expression* value() { return value_; }
private:
FieldInitializer() {}
- Ref<CanonicalName> field_reference_; // Field.
+ Ref<CanonicalName> field_reference_;
Child<Expression> value_;
DISALLOW_COPY_AND_ASSIGN(FieldInitializer);
@@ -883,13 +884,13 @@ class SuperInitializer : public Initializer {
virtual void AcceptInitializerVisitor(InitializerVisitor* visitor);
virtual void VisitChildren(Visitor* visitor);
- CanonicalName* target() { return target_reference_; }
+ Constructor* target() { return target_reference_->AsConstructor(); }
Arguments* arguments() { return arguments_; }
private:
SuperInitializer() {}
- Ref<CanonicalName> target_reference_; // Constructor.
+ Ref<CanonicalName> target_reference_;
Child<Arguments> arguments_;
DISALLOW_COPY_AND_ASSIGN(SuperInitializer);
@@ -907,13 +908,13 @@ class RedirectingInitializer : public Initializer {
virtual void AcceptInitializerVisitor(InitializerVisitor* visitor);
virtual void VisitChildren(Visitor* visitor);
- CanonicalName* target() { return target_reference_; }
+ Constructor* target() { return target_reference_->AsConstructor(); }
Arguments* arguments() { return arguments_; }
private:
RedirectingInitializer() {}
- Ref<CanonicalName> target_reference_; // Constructor.
+ Ref<CanonicalName> target_reference_;
Child<Arguments> arguments_;
DISALLOW_COPY_AND_ASSIGN(RedirectingInitializer);
@@ -1146,13 +1147,13 @@ class DirectPropertyGet : public Expression {
virtual void VisitChildren(Visitor* visitor);
Expression* receiver() { return receiver_; }
- CanonicalName* target() { return target_reference_; }
+ Member* target() { return target_reference_->AsMember(); }
private:
DirectPropertyGet() {}
Child<Expression> receiver_;
- Ref<CanonicalName> target_reference_; // Member.
+ Ref<CanonicalName> target_reference_;
DISALLOW_COPY_AND_ASSIGN(DirectPropertyGet);
};
@@ -1170,14 +1171,14 @@ class DirectPropertySet : public Expression {
virtual void VisitChildren(Visitor* visitor);
Expression* receiver() { return receiver_; }
- CanonicalName* target() { return target_reference_; }
+ Member* target() { return target_reference_->AsMember(); }
Expression* value() { return value_; }
private:
DirectPropertySet() {}
Child<Expression> receiver_;
- Ref<CanonicalName> target_reference_; // Member.
+ Ref<CanonicalName> target_reference_;
Child<Expression> value_;
DISALLOW_COPY_AND_ASSIGN(DirectPropertySet);
@@ -1195,12 +1196,12 @@ class StaticGet : public Expression {
virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
virtual void VisitChildren(Visitor* visitor);
- CanonicalName* target() { return target_reference_; }
+ Member* target() { return target_reference_->AsMember(); }
private:
StaticGet() {}
- Ref<CanonicalName> target_reference_; // Member.
+ Ref<CanonicalName> target_reference_;
DISALLOW_COPY_AND_ASSIGN(StaticGet);
};
@@ -1217,13 +1218,13 @@ class StaticSet : public Expression {
virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
virtual void VisitChildren(Visitor* visitor);
- CanonicalName* target() { return target_reference_; }
+ Member* target() { return target_reference_->AsMember(); }
Expression* expression() { return expression_; }
private:
StaticSet() {}
- Ref<CanonicalName> target_reference_; // Member.
+ Ref<CanonicalName> target_reference_;
Child<Expression> expression_;
DISALLOW_COPY_AND_ASSIGN(StaticSet);
@@ -1323,14 +1324,14 @@ class DirectMethodInvocation : public Expression {
virtual void VisitChildren(Visitor* visitor);
Expression* receiver() { return receiver_; }
- CanonicalName* target() { return target_reference_; }
+ Procedure* target() { return target_reference_->AsProcedure(); }
Arguments* arguments() { return arguments_; }
private:
DirectMethodInvocation() {}
Child<Expression> receiver_;
- Ref<CanonicalName> target_reference_; // Procedure.
+ Ref<CanonicalName> target_reference_;
Child<Arguments> arguments_;
DISALLOW_COPY_AND_ASSIGN(DirectMethodInvocation);
@@ -1345,14 +1346,14 @@ class StaticInvocation : public Expression {
virtual void AcceptExpressionVisitor(ExpressionVisitor* visitor);
virtual void VisitChildren(Visitor* visitor);
- CanonicalName* procedure() { return procedure_reference_; }
+ Procedure* procedure() { return procedure_reference_->AsProcedure(); }
Arguments* arguments() { return arguments_; }
bool is_const() { return is_const_; }
private:
StaticInvocation() {}
- Ref<CanonicalName> procedure_reference_; // Procedure.
+ Ref<CanonicalName> procedure_reference_;
Child<Arguments> arguments_;
bool is_const_;
@@ -1372,14 +1373,14 @@ class ConstructorInvocation : public Expression {
virtual void VisitChildren(Visitor* visitor);
bool is_const() { return is_const_; }
- CanonicalName* target() { return target_reference_; }
+ Constructor* target() { return target_reference_->AsConstructor(); }
Arguments* arguments() { return arguments_; }
private:
ConstructorInvocation() {}
bool is_const_;
- Ref<CanonicalName> target_reference_; // Constructor.
+ Ref<CanonicalName> target_reference_;
Child<Arguments> arguments_;
DISALLOW_COPY_AND_ASSIGN(ConstructorInvocation);
@@ -2528,14 +2529,18 @@ class Name : public Node {
virtual void VisitChildren(Visitor* visitor);
String* string() { return string_; }
- CanonicalName* library() { return library_reference_; }
+ Library* library() {
+ if (library_reference_ == NULL) return NULL;
+ return library_reference_->AsLibrary();
+ }
+ CanonicalName* library_reference() { return library_reference_; }
private:
Name(String* string, CanonicalName* library_reference)
: string_(string), library_reference_(library_reference) {} // NOLINT
Ref<String> string_;
- Ref<CanonicalName> library_reference_; // Library.
+ Ref<CanonicalName> library_reference_;
DISALLOW_COPY_AND_ASSIGN(Name);
};
@@ -2628,13 +2633,14 @@ class InterfaceType : public DartType {
virtual void AcceptDartTypeVisitor(DartTypeVisitor* visitor);
virtual void VisitChildren(Visitor* visitor);
- CanonicalName* klass() { return class_reference_; }
+ Class* klass() { return class_reference_->AsClass(); }
+ CanonicalName* class_reference() { return class_reference_; }
List<DartType>& type_arguments() { return type_arguments_; }
private:
InterfaceType() {}
- Ref<CanonicalName> class_reference_; // Class.
+ Ref<CanonicalName> class_reference_;
List<DartType> type_arguments_;
DISALLOW_COPY_AND_ASSIGN(InterfaceType);
@@ -2739,7 +2745,10 @@ class Program : public TreeNode {
StringTable& source_uri_table() { return source_uri_table_; }
SourceTable& source_table() { return source_table_; }
List<Library>& libraries() { return libraries_; }
- CanonicalName* main_method() { return main_method_reference_; }
+ Procedure* main_method() {
+ if (main_method_reference_ == NULL) return NULL;
+ return main_method_reference_->AsProcedure();
+ }
CanonicalName* canonical_name_root() { return canonical_name_root_; }
MallocGrowableArray<MallocGrowableArray<intptr_t>*> valid_token_positions;
MallocGrowableArray<MallocGrowableArray<intptr_t>*> yield_token_positions;
@@ -2749,7 +2758,7 @@ class Program : public TreeNode {
Child<CanonicalName> canonical_name_root_;
List<Library> libraries_;
- Ref<CanonicalName> main_method_reference_; // Procedure.
+ Ref<CanonicalName> main_method_reference_;
StringTable string_table_;
StringTable source_uri_table_;
SourceTable source_table_;
@@ -3004,6 +3013,37 @@ class DartTypeVisitor {
};
+class ClassReferenceVisitor {
+ public:
+ virtual ~ClassReferenceVisitor() {}
+
+ virtual void VisitDefaultClassReference(Class* node) = 0;
+ virtual void VisitNormalClassReference(NormalClass* node) {
+ VisitDefaultClassReference(node);
+ }
+ virtual void VisitMixinClassReference(MixinClass* node) {
+ VisitDefaultClassReference(node);
+ }
+};
+
+
+class MemberReferenceVisitor {
+ public:
+ virtual ~MemberReferenceVisitor() {}
+
+ virtual void VisitDefaultMemberReference(Member* node) = 0;
+ virtual void VisitFieldReference(Field* node) {
+ VisitDefaultMemberReference(node);
+ }
+ virtual void VisitConstructorReference(Constructor* node) {
+ VisitDefaultMemberReference(node);
+ }
+ virtual void VisitProcedureReference(Procedure* node) {
+ VisitDefaultMemberReference(node);
+ }
+};
+
+
class TreeVisitor : public ExpressionVisitor,
public StatementVisitor,
public MemberVisitor,
@@ -3043,7 +3083,10 @@ class TreeVisitor : public ExpressionVisitor,
};
-class Visitor : public TreeVisitor, public DartTypeVisitor {
+class Visitor : public TreeVisitor,
+ public DartTypeVisitor,
+ public ClassReferenceVisitor,
+ public MemberReferenceVisitor {
public:
virtual ~Visitor() {}
« no previous file with comments | « pkg/kernel/lib/canonical_name.dart ('k') | runtime/vm/kernel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698