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

Unified Diff: lib/compiler/implementation/tree/nodes.dart

Issue 10441044: Refactor common logic of SsaBuilder.visitSend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Next iteration Created 8 years, 7 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/tree/nodes.dart
diff --git a/lib/compiler/implementation/tree/nodes.dart b/lib/compiler/implementation/tree/nodes.dart
index f5aa5adcded14326fc9d60e49603f1ca1b960fd2..332054facb8065b8fb4e90e3e6d1745abee6fe2b 100644
--- a/lib/compiler/implementation/tree/nodes.dart
+++ b/lib/compiler/implementation/tree/nodes.dart
@@ -293,6 +293,54 @@ class Send extends Expression {
assert(receiver === null);
return new Send(newReceiver, selector, argumentsNode);
}
+
+ analyse([
ahe 2012/06/01 13:50:34 To be perfectly clear: I don't like this method.
Anton Muhin 2012/06/01 14:07:06 What will you like more? analyseSubtype? subtype
+ bool methodInterceptionEnabled,
+ TreeElements elements,
+ SendVisitor sendVisitor]) {
+ if (isSuperCall) {
+ return sendVisitor.visitSuperSend(this);
+ } else if (isOperator && methodInterceptionEnabled) {
+ return sendVisitor.visitOperatorSend(this);
+ } else if (isPropertyAccess) {
+ return sendVisitor.visitGetterSend(this);
+ } else if (Elements.isClosureSend(this, elements)) {
+ return sendVisitor.visitClosureSend(this);
+ } else {
+ Element element = elements[this];
+ if (element === null) {
+ // Example: f() with 'f' unbound.
+ // This can only happen inside an instance method.
+ return sendVisitor.visitDynamicSend(this);
+ } else if (element.kind == ElementKind.CLASS) {
+ sendVisitor.internalError("Cannot generate code for send", node: node);
+ } else if (element.isInstanceMember()) {
+ // Example: f() with 'f' bound to instance method.
+ return sendVisitor.visitDynamicSend(this);
+ } else if (element.kind === ElementKind.FOREIGN) {
+ return sendVisitor.visitForeignSend(this);
+ } else if (!element.isInstanceMember()) {
+ // Example: A.f() or f() with 'f' bound to a static function.
+ // Also includes new A() or new A.named() which is treated like a
+ // static call to a factory.
+ return sendVisitor.visitStaticSend(this);
+ } else {
+ sendVisitor.internalError("Cannot generate code for send", node: node);
+ }
+ }
+ }
+}
+
+interface SendVisitor {
+ visitSuperSend(Send node);
+ visitOperatorSend(Send node);
+ visitGetterSend(Send node);
+ visitClosureSend(Send node);
+ visitDynamicSend(Send node);
+ visitForeignSend(Send node);
+ visitStaticSend(Send node);
+
+ internalError(String reason, [Node node]);
}
class Postfix extends NodeList {

Powered by Google App Engine
This is Rietveld 408576698