Index: pkg/compiler/lib/src/elements/common.dart |
diff --git a/pkg/compiler/lib/src/elements/common.dart b/pkg/compiler/lib/src/elements/common.dart |
index 9cdce47251bceacdd2678c0d8217a5b1e0005106..6c9a013451a35f19ce281285945374e4f9bcd130 100644 |
--- a/pkg/compiler/lib/src/elements/common.dart |
+++ b/pkg/compiler/lib/src/elements/common.dart |
@@ -151,6 +151,13 @@ abstract class ElementCommon implements Element { |
} |
return null; |
} |
+ |
+ Element get enclosingClassOrCompilationUnit { |
+ for (Element e = this; e != null; e = e.enclosingElement) { |
+ if (e.isClass || e.isCompilationUnit) return e; |
+ } |
+ return null; |
+ } |
} |
abstract class LibraryElementCommon implements LibraryElement { |
@@ -465,6 +472,36 @@ abstract class ClassElementCommon implements ClassElement { |
bool get isNamedMixinApplication { |
return isMixinApplication && !isUnnamedMixinApplication; |
} |
+ |
+ // backendMembers are members that have been added by the backend to simplify |
+ // compilation. They don't have any user-side counter-part. |
+ Link<Element> backendMembers = const Link<Element>(); |
+ |
+ bool get hasBackendMembers => !backendMembers.isEmpty; |
+ |
+ void addBackendMember(Element member) { |
+ // TODO(ngeoffray): Deprecate this method. |
+ assert(member.isGenerativeConstructorBody); |
+ backendMembers = backendMembers.prepend(member); |
+ } |
+ |
+ void reverseBackendMembers() { |
+ backendMembers = backendMembers.reverse(); |
+ } |
+ |
+ /// Lookup a synthetic element created by the backend. |
+ Element lookupBackendMember(String memberName) { |
+ for (Element element in backendMembers) { |
+ if (element.name == memberName) { |
+ return element; |
+ } |
+ } |
+ return null; |
+ } |
+ |
+ void forEachBackendMember(void f(Element member)) { |
+ backendMembers.forEach(f); |
+ } |
} |
abstract class FunctionSignatureCommon implements FunctionSignature { |