Chromium Code Reviews| Index: dart/lib/compiler/implementation/elements/elements.dart |
| =================================================================== |
| --- dart/lib/compiler/implementation/elements/elements.dart (revision 8049) |
| +++ dart/lib/compiler/implementation/elements/elements.dart (working copy) |
| @@ -354,17 +354,29 @@ |
| } |
| class TypedefElement extends Element { |
| - final Token token; |
| Type cachedType; |
| + Typedef cachedNode; |
| - TypedefElement(SourceString name, Element enclosing, this.token) |
| - : super(name, ElementKind.TYPEDEF, enclosing) { |
| - cachedType = new InterfaceType(this); |
| + TypedefElement(SourceString name, Element enclosing) |
| + : super(name, ElementKind.TYPEDEF, enclosing); |
| + |
| + Type computeType(Compiler compiler) { |
|
ahe
2012/05/29 13:21:50
I'm absolutely 100% lukewarm on this approach. Thi
|
| + if (cachedType !== null) return cachedType; |
| + compiler.withCurrentElement(this, () { |
| + FunctionSignature signature = compiler.resolveTypedef(this); |
| + LinkBuilder<Type> parameterTypes = new LinkBuilder<Type>(); |
| + for (Link<Element> link = signature.requiredParameters; |
| + !link.isEmpty(); |
| + link = link.tail) { |
| + parameterTypes.addLast(link.head.computeType(compiler)); |
| + // TODO(karlklose): optional parameters. |
| + } |
| + cachedType = new FunctionType(compiler.types.dynamicType, |
| + parameterTypes.toLink(), |
| + this); |
| + }); |
| + return cachedType; |
| } |
| - |
| - position() => findMyName(token); |
| - |
| - Type computeType(Compiler compiler) => cachedType; |
| } |
| class VariableElement extends Element { |