Chromium Code Reviews| Index: lib/compiler/implementation/elements/elements.dart |
| diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart |
| index 6736b57ef0d87732f74056afb838ea413bb7c20b..5f3b64070b6ba25ce9c316933b7e17e53e673e61 100644 |
| --- a/lib/compiler/implementation/elements/elements.dart |
| +++ b/lib/compiler/implementation/elements/elements.dart |
| @@ -216,12 +216,15 @@ class Element implements Hashable { |
| String toString() { |
| // TODO(johnniwinther): Test for nullness of name, or make non-nullness an |
| - // invariant for all element types. |
| + // invariant for all element types? |
| + var nameText = name !== null ? name.slowToString() : '?'; |
| if (enclosingElement !== null && !isTopLevel()) { |
| - String holderName = enclosingElement.name.slowToString(); |
| - return '$kind($holderName#${name.slowToString()})'; |
| + String holderName = enclosingElement.name !== null |
| + ? enclosingElement.name.slowToString() |
| + : '${enclosingElement.kind}?'; |
| + return '$kind($holderName#${nameText})'; |
| } else { |
| - return '$kind(${name.slowToString()})'; |
| + return '$kind(${nameText})'; |
| } |
| } |
| @@ -500,6 +503,13 @@ class VariableListElement extends Element { |
| Type type; |
| final Modifiers modifiers; |
| + /** |
| + * Function signature for variable of a function type. The signature is kept |
|
floitsch
2012/07/17 18:53:04
for variables with a function type.
Johnni Winther
2012/07/18 13:32:50
Done.
|
| + * in order to provide full information about parameter names through the |
|
floitsch
2012/07/17 18:53:04
remove "in order".
Johnni Winther
2012/07/18 13:32:50
Done.
|
| + * the mirror system. |
| + */ |
| + FunctionSignature functionSignature; |
| + |
| VariableListElement(ElementKind kind, |
| Modifiers this.modifiers, |
| Element enclosing) |
| @@ -518,7 +528,29 @@ class VariableListElement extends Element { |
| Type computeType(Compiler compiler) { |
| if (type != null) return type; |
| - type = compiler.resolveTypeAnnotation(this, parseNode(compiler).type); |
| + var node = parseNode(compiler); |
|
floitsch
2012/07/17 18:53:04
s/var/Node.
Johnni Winther
2012/07/18 13:32:50
Done.
|
| + if (node.type !== null) { |
| + type = compiler.resolveTypeAnnotation(this, node.type); |
| + } else { |
| + // Is node.definitions exactly one FunctionExpression? |
| + var link = node.definitions.nodes; |
|
floitsch
2012/07/17 18:53:04
s/var/Link
Johnni Winther
2012/07/18 13:32:50
Done.
|
| + if (!link.isEmpty() && |
| + link.head is FunctionExpression && |
|
floitsch
2012/07/17 18:53:04
.asFunctionExpression() != null
Johnni Winther
2012/07/18 13:32:50
Done.
|
| + link.tail.isEmpty()) |
| + { |
|
floitsch
2012/07/17 18:53:04
move into previous line.
Johnni Winther
2012/07/18 13:32:50
Done.
|
| + var functionExpression = link.head; |
|
floitsch
2012/07/17 18:53:04
s/var/FunctionExpression
Johnni Winther
2012/07/18 13:32:50
Done.
|
| + // We found exactly one FunctionExpression |
| + compiler.withCurrentElement(this, () { |
| + functionSignature = compiler.resolveFunctionExpression( |
|
floitsch
2012/07/17 18:53:04
nit: I would prefer a new line after the "=" (if i
Johnni Winther
2012/07/18 13:32:50
Done.
|
| + this, functionExpression); |
| + }); |
| + type = compiler.computeFunctionType(compiler.functionClass, |
| + functionSignature); |
| + } else { |
| + type = compiler.types.dynamicType; |
| + } |
| + } |
| + assert(type != null); |
| return type; |
| } |