| Index: frog/leg/elements/elements.dart
|
| diff --git a/frog/leg/elements/elements.dart b/frog/leg/elements/elements.dart
|
| index 9f7f864f28ded716a3632b58bd3d364f8fd87a4d..92531a8c0ff638629d1746ea3e748eb3e34671da 100644
|
| --- a/frog/leg/elements/elements.dart
|
| +++ b/frog/leg/elements/elements.dart
|
| @@ -214,11 +214,12 @@ class FunctionElement extends Element {
|
| Modifiers this.modifiers,
|
| Element enclosing)
|
| : super(name, kind, enclosing);
|
| - FunctionElement.node(FunctionExpression node,
|
| + FunctionElement.node(SourceString name,
|
| + FunctionExpression node,
|
| ElementKind kind,
|
| Modifiers this.modifiers,
|
| Element enclosing)
|
| - : super(node.name.asIdentifier().source, kind, enclosing),
|
| + : super(name, kind, enclosing),
|
| this.node = node;
|
|
|
| bool isInstanceMember() {
|
| @@ -297,6 +298,8 @@ class ClassElement extends Element {
|
| Type type;
|
| Type supertype;
|
| Link<Element> members = const EmptyLink<Element>();
|
| + Map<SourceString, Element> localMembers;
|
| + Map<SourceString, Element> constructors;
|
| Link<Type> interfaces = const EmptyLink<Type>();
|
| bool isResolved = false;
|
| ClassNode node;
|
| @@ -306,10 +309,18 @@ class ClassElement extends Element {
|
| SynthesizedConstructorElement synthesizedConstructor;
|
|
|
| ClassElement(SourceString name, CompilationUnitElement enclosing)
|
| - : super(name, ElementKind.CLASS, enclosing);
|
| + : localMembers = new Map<SourceString, Element>(),
|
| + constructors = new Map<SourceString, Element>(),
|
| + super(name, ElementKind.CLASS, enclosing);
|
|
|
| void addMember(Element element) {
|
| members = members.prepend(element);
|
| + if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR ||
|
| + element.modifiers.isFactory()) {
|
| + constructors[element.name] = element;
|
| + } else {
|
| + localMembers[element.name] = element;
|
| + }
|
| }
|
|
|
| Type computeType(compiler) {
|
| @@ -327,36 +338,20 @@ class ClassElement extends Element {
|
| return this;
|
| }
|
|
|
| - Element lookupLocalElement(SourceString name, bool matches(Element)) {
|
| - // TODO(karlklose): replace with more efficient solution.
|
| - for (Link<Element> link = members;
|
| - link !== null && !link.isEmpty();
|
| - link = link.tail) {
|
| - Element element = link.head;
|
| - if (matches(element)) return element;
|
| - }
|
| - return null;
|
| - }
|
| -
|
| Element lookupLocalMember(SourceString name) {
|
| - bool matches(Element element) {
|
| - return element.name == name
|
| - && element.kind != ElementKind.GENERATIVE_CONSTRUCTOR;
|
| - }
|
| - return lookupLocalElement(name, matches);
|
| + return localMembers[name];
|
| }
|
|
|
| - Element lookupConstructor(SourceString name) {
|
| - bool matches(Element element) {
|
| - return element.name == name
|
| - && (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR
|
| - || element.modifiers.isFactory());
|
| + Element lookupConstructor(SourceString name, [Element noMatch(Element)]) {
|
| + Element result = constructors[name];
|
| + if (result === null && noMatch !== null) {
|
| + result = noMatch(lookupLocalMember(name));
|
| }
|
| - return lookupLocalElement(name, matches);
|
| + return result;
|
| }
|
|
|
| // TODO(ngeoffray): Implement these.
|
| - bool canHaveDefaultConstructor() => true;
|
| + bool canHaveDefaultConstructor() => constructors.length == 0;
|
|
|
| SynthesizedConstructorElement getSynthesizedConstructor() {
|
| if (synthesizedConstructor === null && canHaveDefaultConstructor()) {
|
|
|