Index: pkg/compiler/lib/src/elements/modelx.dart |
diff --git a/pkg/compiler/lib/src/elements/modelx.dart b/pkg/compiler/lib/src/elements/modelx.dart |
index 36d6593a03750bd49336a8cfe573134f2a7c5505..8d905077bf0b0c67012c6178bac10fd2e4322033 100644 |
--- a/pkg/compiler/lib/src/elements/modelx.dart |
+++ b/pkg/compiler/lib/src/elements/modelx.dart |
@@ -171,7 +171,7 @@ abstract class ElementX extends Element { |
Name get memberName => new Name(name, library); |
- LibraryElement get implementationLibrary { |
+ LibraryElementX get implementationLibrary { |
Element element = this; |
while (!identical(element.kind, ElementKind.LIBRARY)) { |
element = element.enclosingElement; |
@@ -421,9 +421,7 @@ class ErroneousConstructorElementX extends ErroneousElementX |
throw new UnsupportedError("nestedClosures="); |
} |
- bool get hasNoBody => false; |
- |
- bool get _hasNoBody => false; |
sigurdm
2015/05/08 11:20:48
Beautiful!
|
+ bool get hasBody => true; |
sigurdm
2015/05/08 11:20:48
Does not seem like the right abstraction.
Add TODO
Johnni Winther
2015/05/11 14:06:59
Removed.
|
void set effectiveTarget(_) { |
throw new UnsupportedError("effectiveTarget="); |
@@ -615,7 +613,7 @@ class ScopeX { |
* element, they are enclosed by the class or compilation unit, as is the |
* abstract field. |
*/ |
- void addAccessor(FunctionElementX accessor, |
+ void addAccessor(AccessorElementX accessor, |
Element existing, |
DiagnosticListener listener) { |
void reportError(Element other) { |
@@ -673,7 +671,7 @@ class CompilationUnitElementX extends ElementX |
PartOf partTag; |
Link<Element> localMembers = const Link<Element>(); |
- CompilationUnitElementX(Script script, LibraryElement library) |
+ CompilationUnitElementX(Script script, LibraryElementX library) |
: this.script = script, |
super(script.name, |
ElementKind.COMPILATION_UNIT, |
@@ -681,6 +679,9 @@ class CompilationUnitElementX extends ElementX |
library.addCompilationUnit(this); |
} |
+ @override |
+ LibraryElementX get library => enclosingElement.declaration; |
+ |
void forEachLocalMember(f(Element element)) { |
localMembers.forEach(f); |
} |
@@ -932,6 +933,7 @@ class LibraryElementX |
return tagsCache; |
} |
+ /// Record which element an import or export tag resolved to. |
void recordResolvedTag(LibraryDependency tag, LibraryElement library) { |
assert(tagMapping[tag] == null); |
tagMapping[tag] = library; |
@@ -1678,8 +1680,8 @@ class ErroneousInitializingFormalElementX extends ParameterElementX |
} |
class AbstractFieldElementX extends ElementX implements AbstractFieldElement { |
- FunctionElementX getter; |
- FunctionElementX setter; |
+ MethodElementX getter; |
sigurdm
2015/05/08 11:20:48
Could you even say:
GetterElementX getter;
?
Johnni Winther
2015/05/11 14:06:59
Done.
|
+ MethodElementX setter; |
AbstractFieldElementX(String name, Element enclosing) |
: super(name, ElementKind.ABSTRACT_FIELD, enclosing); |
@@ -1837,26 +1839,18 @@ abstract class BaseFunctionElementX |
FunctionSignature functionSignatureCache; |
- final bool _hasNoBody; |
- |
- AbstractFieldElement abstractField; |
- |
AsyncMarker asyncMarker = AsyncMarker.SYNC; |
BaseFunctionElementX(String name, |
ElementKind kind, |
Modifiers this.modifiers, |
- Element enclosing, |
- bool hasNoBody) |
- : super(name, kind, enclosing), |
- _hasNoBody = hasNoBody { |
+ Element enclosing) |
+ : super(name, kind, enclosing) { |
assert(modifiers != null); |
} |
bool get isExternal => modifiers.isExternal; |
- bool get hasNoBody => _hasNoBody; |
- |
bool get isInstanceMember { |
return isClassMember |
&& !isConstructor |
@@ -1911,11 +1905,7 @@ abstract class BaseFunctionElementX |
} |
} |
- bool get isAbstract { |
- return !modifiers.isExternal && |
- (isFunction || isAccessor) && |
- _hasNoBody; |
- } |
+ bool get isAbstract => false; |
accept(ElementVisitor visitor, arg) { |
return visitor.visitFunctionElement(this, arg); |
@@ -1927,12 +1917,12 @@ abstract class BaseFunctionElementX |
abstract class FunctionElementX extends BaseFunctionElementX |
with AnalyzableElementX implements MethodElement { |
+ |
FunctionElementX(String name, |
ElementKind kind, |
Modifiers modifiers, |
- Element enclosing, |
- bool hasNoBody) |
- : super(name, kind, modifiers, enclosing, hasNoBody); |
+ Element enclosing) |
+ : super(name, kind, modifiers, enclosing); |
MemberElement get memberContext => this; |
@@ -1944,6 +1934,55 @@ abstract class FunctionElementX extends BaseFunctionElementX |
} |
} |
+abstract class MethodElementX extends FunctionElementX { |
+ final bool hasBody; |
+ |
+ MethodElementX(String name, |
+ ElementKind kind, |
+ Modifiers modifiers, |
+ Element enclosing, |
+ // TODO(15101): Make this a named parameter. |
+ this.hasBody) |
+ : super(name, kind, modifiers, enclosing); |
+ |
+ @override |
+ bool get isAbstract { |
+ return !modifiers.isExternal && !hasBody; |
+ } |
+} |
+ |
+abstract class AccessorElementX extends MethodElementX |
+ implements AccessorElement { |
+ AbstractFieldElement abstractField; |
+ |
+ AccessorElementX(String name, |
+ ElementKind kind, |
+ Modifiers modifiers, |
+ Element enclosing, |
+ bool hasBody) |
+ : super(name, kind, modifiers, enclosing, hasBody); |
+} |
+ |
+abstract class GetterElementX extends AccessorElementX |
+ implements GetterElement { |
+ |
+ GetterElementX(String name, |
+ Modifiers modifiers, |
+ Element enclosing, |
+ bool hasBody) |
+ : super(name, ElementKind.GETTER, modifiers, enclosing, hasBody); |
+} |
+ |
+abstract class SetterElementX extends AccessorElementX |
+ implements SetterElement { |
+ |
+ SetterElementX(String name, |
+ Modifiers modifiers, |
+ Element enclosing, |
+ bool hasBody) |
+ : super(name, ElementKind.SETTER, modifiers, enclosing, hasBody); |
+} |
+ |
class LocalFunctionElementX extends BaseFunctionElementX |
implements LocalFunctionElement { |
final FunctionExpression node; |
@@ -1953,7 +1992,7 @@ class LocalFunctionElementX extends BaseFunctionElementX |
ElementKind kind, |
Modifiers modifiers, |
ExecutableElement enclosing) |
- : super(name, kind, modifiers, enclosing, false); |
+ : super(name, kind, modifiers, enclosing); |
ExecutableElement get executableContext => enclosingElement; |
@@ -2007,7 +2046,7 @@ abstract class ConstructorElementX extends FunctionElementX |
ElementKind kind, |
Modifiers modifiers, |
Element enclosing) |
- : super(name, kind, modifiers, enclosing, false); |
+ : super(name, kind, modifiers, enclosing); |
FunctionElement immediateRedirectionTarget; |
@@ -2038,20 +2077,25 @@ abstract class ConstructorElementX extends FunctionElementX |
return effectiveTargetType.substByContext(newType); |
} |
+ accept(ElementVisitor visitor, arg) { |
+ return visitor.visitConstructorElement(this, arg); |
+ } |
+ |
ConstructorElement get definingConstructor => null; |
ClassElement get enclosingClass => enclosingElement; |
} |
-class DeferredLoaderGetterElementX extends FunctionElementX { |
+class DeferredLoaderGetterElementX extends GetterElementX |
+ implements GetterElement { |
final PrefixElement prefix; |
DeferredLoaderGetterElementX(PrefixElement prefix) |
: this.prefix = prefix, |
super("loadLibrary", |
- ElementKind.FUNCTION, |
Modifiers.EMPTY, |
- prefix, true); |
+ prefix, |
+ false); |
FunctionSignature computeSignature(Compiler compiler) { |
if (functionSignatureCache != null) return functionSignature; |
@@ -2068,12 +2112,8 @@ class DeferredLoaderGetterElementX extends FunctionElementX { |
bool get isSynthesized => true; |
- bool get isFunction => false; |
- |
bool get isDeferredLoaderGetter => true; |
- bool get isGetter => true; |
- |
bool get isTopLevel => true; |
// By having position null, the enclosing elements location is printed in |
// error messages. |
@@ -2084,18 +2124,21 @@ class DeferredLoaderGetterElementX extends FunctionElementX { |
bool get hasNode => false; |
FunctionExpression get node => null; |
+ |
+ @override |
+ SetterElement get setter => null; |
} |
class ConstructorBodyElementX extends BaseFunctionElementX |
implements ConstructorBodyElement { |
- ConstructorElement constructor; |
+ ConstructorElementX constructor; |
- ConstructorBodyElementX(FunctionElement constructor) |
+ ConstructorBodyElementX(ConstructorElementX constructor) |
: this.constructor = constructor, |
super(constructor.name, |
ElementKind.GENERATIVE_CONSTRUCTOR_BODY, |
Modifiers.EMPTY, |
- constructor.enclosingElement, false) { |
+ constructor.enclosingElement) { |
functionSignatureCache = constructor.functionSignature; |
} |
@@ -2833,18 +2876,14 @@ class EnumConstructorElementX extends ConstructorElementX { |
FunctionExpression parseNode(Compiler compiler) => node; |
} |
-class EnumMethodElementX extends FunctionElementX { |
+class EnumMethodElementX extends MethodElementX { |
final FunctionExpression node; |
EnumMethodElementX(String name, |
EnumClassElementX enumClass, |
Modifiers modifiers, |
this.node) |
- : super(name, |
- ElementKind.FUNCTION, |
- modifiers, |
- enumClass, |
- false); |
+ : super(name, ElementKind.FUNCTION, modifiers, enumClass, true); |
@override |
bool get hasNode => true; |