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

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
Index: frog/leg/elements/elements.dart
===================================================================
--- frog/leg/elements/elements.dart (revision 2741)
+++ 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;
}
@@ -168,7 +169,8 @@
bool isInstanceMember() {
return isMember()
- && kind != ElementKind.CONSTRUCTOR
+ && kind != ElementKind.GENERATIVE_CONSTRUCTOR
+ && !modifiers.isFactory()
&& !modifiers.isStatic();
}
@@ -178,7 +180,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) {
@@ -197,7 +199,7 @@
ConstructorBodyElement(FunctionElement constructor)
: this.constructor = constructor,
super(constructor.name,
- ElementKind.CONSTRUCTOR_BODY,
+ ElementKind.GENERATIVE_CONSTRUCTOR_BODY,
null,
constructor.enclosingElement) {
assert(constructor.node !== null);
@@ -214,7 +216,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>();
}
@@ -282,7 +285,7 @@
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);
}
@@ -290,7 +293,8 @@
Element lookupConstructor(SourceString name) {
bool matches(Element 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') | frog/leg/lib/core.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698