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

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: 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
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;
}

Powered by Google App Engine
This is Rietveld 408576698