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

Unified Diff: frog/leg/elements/elements.dart

Issue 9027002: Support factory methods. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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 | « frog/leg/compiler.dart ('k') | frog/leg/emitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/elements/elements.dart
===================================================================
--- frog/leg/elements/elements.dart (revision 2754)
+++ frog/leg/elements/elements.dart (working copy)
@@ -29,12 +29,13 @@
static final ElementKind FUNCTION = const ElementKind('function');
static final ElementKind CLASS = const ElementKind('class');
static final ElementKind FOREIGN = const ElementKind('foreign');
- static final ElementKind CONSTRUCTOR = const ElementKind('constructor');
+ static final ElementKind GENERATIVE_CONSTRUCTOR =
+ const ElementKind('generative_constructor');
static final ElementKind FIELD = const ElementKind('field');
static final ElementKind VARIABLE_LIST = const ElementKind('variable_list');
static final ElementKind FIELD_LIST = const ElementKind('field_list');
- static final ElementKind CONSTRUCTOR_BODY =
- const ElementKind('constructor_body');
+ static final ElementKind GENERATIVE_CONSTRUCTOR_BODY =
+ const ElementKind('generative_constructor_body');
toString() => id;
}
@@ -48,6 +49,7 @@
bool isMember() =>
enclosingElement !== null && enclosingElement.kind == ElementKind.CLASS;
bool isInstanceMember() => false;
+ bool isGenerativeConstructor() => kind == ElementKind.GENERATIVE_CONSTRUCTOR;
const Element(this.name, this.kind, this.enclosingElement);
@@ -173,7 +175,8 @@
bool isInstanceMember() {
return isMember()
- && kind != ElementKind.CONSTRUCTOR
+ && kind != ElementKind.GENERATIVE_CONSTRUCTOR
+ && !modifiers.isFactory()
&& !modifiers.isStatic();
}
@@ -183,7 +186,7 @@
FunctionExpression node =
compiler.parser.measure(() => parseNode(compiler, compiler));
Type returnType = getType(node.returnType, compiler, types);
- if (returnType === null) compiler.cancel('unknown type ${node.returnType}');
+ if (returnType === null) returnType = types.dynamicType;
LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>();
for (Link<Element> link = parameters; !link.isEmpty(); link = link.tail) {
@@ -202,7 +205,7 @@
ConstructorBodyElement(FunctionElement constructor)
: this.constructor = constructor,
super(constructor.name,
- ElementKind.CONSTRUCTOR_BODY,
+ ElementKind.GENERATIVE_CONSTRUCTOR_BODY,
null,
constructor.enclosingElement) {
assert(constructor.node !== null);
@@ -219,7 +222,8 @@
class SynthesizedConstructorElement extends FunctionElement {
SynthesizedConstructorElement(Element enclosing)
- : super(enclosing.name, ElementKind.CONSTRUCTOR, null, enclosing) {
+ : super(enclosing.name, ElementKind.GENERATIVE_CONSTRUCTOR,
+ null, enclosing) {
parameters = const EmptyLink<Element>();
}
@@ -287,15 +291,16 @@
Element lookupLocalMember(SourceString name) {
bool matches(Element element) {
return element.name == name
- && element.kind != ElementKind.CONSTRUCTOR;
+ && element.kind != ElementKind.GENERATIVE_CONSTRUCTOR;
}
return lookupLocalElement(name, matches);
}
Element lookupConstructor(SourceString name) {
- bool matches(Element element) {
+ bool matches(FunctionElement element) {
return element.name == name
- && element.kind == ElementKind.CONSTRUCTOR;
+ && (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR
+ || element.modifiers.isFactory());
}
return lookupLocalElement(name, matches);
}
« no previous file with comments | « frog/leg/compiler.dart ('k') | frog/leg/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698