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

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: Cosmetic changes (comments). 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') | frog/leg/emitter.dart » ('J')
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..529243add221d089cf5ec4014460f57a06220ef4 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,33 @@ 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 an invocation of the
ngeoffray 2012/02/17 10:19:26 followed by
floitsch 2012/02/17 13:19:32 Done.
+ // returned closure.
+ Set<Selector> invokedSelectors = universe.invokedNames[member.name];
+ if (invokedSelectors !== null && !invokedSelectors.isEmpty()) {
ngeoffray 2012/02/17 10:19:26 Please add a comment that you cannot know if the s
floitsch 2012/02/17 13:19:32 Done.
+ 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') | frog/leg/emitter.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698