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

Unified Diff: frog/leg/compiler.dart

Issue 9414010: Allow method-calls to getters (assuming they contain closures). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments and update status file. Created 8 years, 10 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 | « no previous file | frog/leg/emitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/compiler.dart
diff --git a/frog/leg/compiler.dart b/frog/leg/compiler.dart
index 35ff15a87e2a604df43fd462f12ccc874b5287bb..a6b82a19ffe64472e78110ae231dae948179b734 100644
--- a/frog/leg/compiler.dart
+++ b/frog/leg/compiler.dart
@@ -186,6 +186,7 @@ class Compiler implements DiagnosticListener {
void enqueueInvokedInstanceMethods() {
// TODO(floitsch): find a more efficient way of doing this.
+
// Run through the classes and see if we need to compile methods.
for (ClassElement classElement in universe.instantiatedClasses) {
for (ClassElement currentClass = classElement;
@@ -215,11 +216,35 @@ class Compiler implements DiagnosticListener {
if (universe.invokedGetters.contains(member.name)) {
addToWorklist(member);
}
+ // A method invocation like in o.foo(x, y) might actually be an
+ // invocation of the getter foo followed by an invocation of the
+ // returned closure.
+ Set<Selector> invokedSelectors = universe.invokedNames[member.name];
+ // We don't know what selectors the returned closure accepts. If
+ // the set contains any selector we have to assume that it matches.
+ if (invokedSelectors !== null && !invokedSelectors.isEmpty()) {
+ addToWorklist(member);
+ }
} else if (member.kind === ElementKind.SETTER) {
if (universe.invokedSetters.contains(member.name)) {
addToWorklist(member);
}
}
+
+ // Make sure that the closure understands a call with the given
+ // selector. For a method-invocation of the form o.foo(a: 499), we
+ // need to make sure that closures can handle the optional argument if
+ // there exists a field or getter 'foo'.
+ if (member.kind === ElementKind.GETTER ||
+ member.kind === ElementKind.FIELD) {
+ Set<Selector> invokedSelectors = universe.invokedNames[member.name];
+ if (invokedSelectors != null) {
+ for (Selector selector in invokedSelectors) {
+ registerDynamicInvocation(Namer.CLOSURE_INVOCATION_NAME,
+ selector);
+ }
+ }
+ }
}
}
}
« no previous file with comments | « no previous file | frog/leg/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698