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

Unified Diff: lib/compiler/implementation/elements/elements.dart

Issue 10779010: Parameters with function types supported + Added features in mirrors implementation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 8 years, 5 months 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
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/elements/elements.dart
diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart
index 05048c593d69f67435c919546f886ea14305f649..a104749521a57a0089f9f97975d1dc8d53b23074 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 a variable with a function type. The signature is
+ * kept to provide full information about parameter names through the the
+ * mirror system.
+ */
+ FunctionSignature functionSignature;
ahe 2012/08/02 19:20:25 We plan to turn this into a type, right?
+
VariableListElement(ElementKind kind,
Modifiers this.modifiers,
Element enclosing)
@@ -518,7 +528,28 @@ class VariableListElement extends Element {
Type computeType(Compiler compiler) {
if (type != null) return type;
- type = compiler.resolveTypeAnnotation(this, parseNode(compiler).type);
+ VariableDefinitions node = parseNode(compiler);
+ if (node.type !== null) {
+ type = compiler.resolveTypeAnnotation(this, node.type);
+ } else {
ahe 2012/08/02 19:20:25 We are already changing this, right? This looks sc
+ // Is node.definitions exactly one FunctionExpression?
+ Link<Node> link = node.definitions.nodes;
+ if (!link.isEmpty() &&
+ link.head.asFunctionExpression() !== null &&
+ link.tail.isEmpty()) {
+ FunctionExpression functionExpression = link.head;
+ // We found exactly one FunctionExpression
+ compiler.withCurrentElement(this, () {
+ functionSignature =
+ compiler.resolveFunctionExpression(this, functionExpression);
+ });
+ type = compiler.computeFunctionType(compiler.functionClass,
+ functionSignature);
+ } else {
+ type = compiler.types.dynamicType;
+ }
+ }
+ assert(type != null);
return type;
}
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698