Chromium Code Reviews| Index: frog/leg/elements/elements.dart |
| =================================================================== |
| --- frog/leg/elements/elements.dart (revision 2746) |
| +++ 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 = |
|
ahe
2011/12/22 13:32:39
I like using terminology from the specification.
|
| + 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); |
| @@ -168,7 +170,8 @@ |
| bool isInstanceMember() { |
| return isMember() |
| - && kind != ElementKind.CONSTRUCTOR |
| + && kind != ElementKind.GENERATIVE_CONSTRUCTOR |
| + && !modifiers.isFactory() |
| && !modifiers.isStatic(); |
| } |
| @@ -178,7 +181,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 +200,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 +217,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,15 +286,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); |
| } |