Index: pkg/compiler/lib/src/scanner/listener.dart |
diff --git a/pkg/compiler/lib/src/scanner/listener.dart b/pkg/compiler/lib/src/scanner/listener.dart |
index 568577a86c183b060d20921c58f35bfbf7fa7d4a..4add7ec1f9afb688499808a30c550c527b541a5f 100644 |
--- a/pkg/compiler/lib/src/scanner/listener.dart |
+++ b/pkg/compiler/lib/src/scanner/listener.dart |
@@ -786,7 +786,7 @@ typedef int IdGenerator(); |
class ElementListener extends Listener { |
final IdGenerator idGenerator; |
final DiagnosticListener listener; |
- final CompilationUnitElement compilationUnitElement; |
+ final CompilationUnitElementX compilationUnitElement; |
final StringValidator stringValidator; |
Link<StringQuoting> interpolationScope; |
@@ -1011,17 +1011,9 @@ class ElementListener extends Listener { |
Identifier name = popNode(); |
TypeAnnotation type = popNode(); |
Modifiers modifiers = popNode(); |
- ElementKind kind; |
- if (getOrSet == null) { |
- kind = ElementKind.FUNCTION; |
- } else if (identical(getOrSet.stringValue, 'get')) { |
- kind = ElementKind.GETTER; |
- } else if (identical(getOrSet.stringValue, 'set')) { |
- kind = ElementKind.SETTER; |
- } |
PartialFunctionElement element = new PartialFunctionElement( |
- name.source, beginToken, getOrSet, endToken, kind, modifiers, |
- compilationUnitElement, false); |
+ name.source, beginToken, getOrSet, endToken, |
+ modifiers, compilationUnitElement); |
element.hasParseError = hasParseError; |
pushElement(element); |
} |
@@ -1327,7 +1319,7 @@ class ElementListener extends Listener { |
compilationUnitElement.addMember(element, listener); |
} |
- Link<MetadataAnnotation> popMetadata(Element element) { |
+ Link<MetadataAnnotation> popMetadata(ElementX element) { |
var result = const Link<MetadataAnnotation>(); |
for (Link link = metadata; !link.isEmpty; link = link.tail) { |
element.addMetadata(link.head); |
@@ -1346,7 +1338,9 @@ class ElementListener extends Listener { |
if (!allowLibraryTags()) { |
recoverableError(tag, 'Library tags not allowed here.'); |
} |
- compilationUnitElement.implementationLibrary.addTag(tag, listener); |
+ LibraryElementX implementationLibrary = |
+ compilationUnitElement.implementationLibrary; |
+ implementationLibrary.addTag(tag, listener); |
} |
void pushNode(Node node) { |
@@ -1563,17 +1557,10 @@ class NodeListener extends ElementListener { |
Identifier name = popNode(); |
TypeAnnotation type = popNode(); |
Modifiers modifiers = popNode(); |
- ElementKind kind; |
- if (getOrSet == null) { |
- kind = ElementKind.FUNCTION; |
- } else if (identical(getOrSet.stringValue, 'get')) { |
- kind = ElementKind.GETTER; |
- } else if (identical(getOrSet.stringValue, 'set')) { |
- kind = ElementKind.SETTER; |
- } |
- pushElement(new PartialFunctionElement(name.source, beginToken, getOrSet, |
- endToken, kind, modifiers, |
- compilationUnitElement, false)); |
+ PartialFunctionElement element = new PartialFunctionElement( |
+ name.source, beginToken, getOrSet, endToken, |
+ modifiers, compilationUnitElement); |
+ pushElement(element); |
} |
void endFormalParameter(Token thisKeyword) { |
@@ -2282,7 +2269,7 @@ abstract class PartialElement implements DeclarationSite { |
DeclarationSite get declarationSite => this; |
} |
-abstract class PartialFunctionMixin implements FunctionElement { |
+abstract class PartialFunctionMixin implements BaseFunctionElementX { |
FunctionExpression cachedNode; |
Modifiers get modifiers; |
Token beginToken; |
@@ -2336,18 +2323,48 @@ abstract class PartialFunctionMixin implements FunctionElement { |
DeclarationSite get declarationSite; |
} |
-class PartialFunctionElement extends FunctionElementX |
- with PartialElement, PartialFunctionMixin { |
- PartialFunctionElement(String name, |
- Token beginToken, |
- Token getOrSet, |
- Token endToken, |
- ElementKind kind, |
- Modifiers modifiers, |
- Element enclosing, |
- bool hasNoBody) |
- : super(name, kind, modifiers, enclosing, hasNoBody) { |
- init(beginToken, getOrSet, endToken); |
+abstract class PartialFunctionElement |
+ implements PartialElement, PartialFunctionMixin { |
+ |
+ factory PartialFunctionElement( |
+ String name, |
+ Token beginToken, |
+ Token getOrSet, |
+ Token endToken, |
+ Modifiers modifiers, |
+ Element enclosingElement, |
+ {bool hasBody: true}) { |
+ if (getOrSet == null) { |
+ return new PartialMethodElement( |
+ name, beginToken, endToken, modifiers, |
+ enclosingElement, hasBody: hasBody); |
+ } else if (identical(getOrSet.stringValue, 'get')) { |
+ return new PartialGetterElement( |
+ name, beginToken, getOrSet, endToken, modifiers, |
+ enclosingElement, hasBody: hasBody); |
+ } else { |
+ assert(identical(getOrSet.stringValue, 'set')); |
+ return new PartialSetterElement( |
+ name, beginToken, getOrSet, endToken, modifiers, |
+ enclosingElement, hasBody: hasBody); |
+ } |
+ } |
+ |
+ PartialFunctionElement copyWithEnclosing(Element enclosing); |
+} |
+ |
+ |
+class PartialMethodElement extends MethodElementX |
+ with PartialElement, PartialFunctionMixin |
+ implements PartialFunctionElement { |
+ PartialMethodElement(String name, |
+ Token beginToken, |
+ Token endToken, |
+ Modifiers modifiers, |
+ Element enclosing, |
+ {bool hasBody: true}) |
+ : super(name, ElementKind.FUNCTION, modifiers, enclosing, hasBody) { |
+ init(beginToken, null, endToken); |
} |
void reuseElement() { |
@@ -2355,10 +2372,67 @@ class PartialFunctionElement extends FunctionElementX |
reusePartialFunctionMixin(); |
} |
- PartialFunctionElement copyWithEnclosing(Element enclosing) { |
- return new PartialFunctionElement( |
- name, beginToken, getOrSet, endToken, kind, modifiers, enclosing, |
- hasNoBody); |
+ PartialMethodElement copyWithEnclosing(Element enclosing) { |
+ return new PartialMethodElement( |
+ name, beginToken, endToken, modifiers, enclosing, hasBody: hasBody); |
+ } |
+} |
+ |
+class PartialGetterElement extends GetterElementX |
+ with PartialElement, PartialFunctionMixin |
+ implements GetterElement, PartialFunctionElement { |
+ PartialGetterElement(String name, |
+ Token beginToken, |
+ Token getToken, |
+ Token endToken, |
+ Modifiers modifiers, |
+ Element enclosing, |
+ {bool hasBody: true}) |
+ : super(name, modifiers, enclosing, hasBody) { |
+ init(beginToken, getToken, endToken); |
+ } |
+ |
+ @override |
+ SetterElement get setter => abstractField.setter; |
+ |
+ void reuseElement() { |
+ super.reuseElement(); |
+ reusePartialFunctionMixin(); |
+ } |
+ |
+ PartialGetterElement copyWithEnclosing(Element enclosing) { |
+ return new PartialGetterElement( |
+ name, beginToken, getOrSet, endToken, modifiers, enclosing, |
+ hasBody: hasBody); |
+ } |
+} |
+ |
+class PartialSetterElement extends SetterElementX |
+ with PartialElement, PartialFunctionMixin |
+ implements SetterElement, PartialFunctionElement { |
+ PartialSetterElement(String name, |
+ Token beginToken, |
+ Token setToken, |
+ Token endToken, |
+ Modifiers modifiers, |
+ Element enclosing, |
+ {bool hasBody: true}) |
+ : super(name, modifiers, enclosing, hasBody) { |
+ init(beginToken, setToken, endToken); |
+ } |
+ |
+ @override |
+ GetterElement get getter => abstractField.getter; |
+ |
+ void reuseElement() { |
+ super.reuseElement(); |
+ reusePartialFunctionMixin(); |
+ } |
+ |
+ PartialSetterElement copyWithEnclosing(Element enclosing) { |
+ return new PartialSetterElement( |
+ name, beginToken, getOrSet, endToken, modifiers, enclosing, |
+ hasBody: hasBody); |
} |
} |
@@ -2506,7 +2580,7 @@ class PartialMetadataAnnotation extends MetadataAnnotationX |
Node parse( |
DiagnosticListener diagnosticListener, |
- Element element, |
+ ElementX element, |
PartialElement partial, |
doParse(Parser parser)) { |
CompilationUnitElement unit = element.compilationUnit; |