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

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

Issue 10441044: Refactor common logic of SsaBuilder.visitSend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor typo Created 8 years, 6 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/leg.dart ('k') | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/resolved_visitor.dart
diff --git a/lib/compiler/implementation/resolved_visitor.dart b/lib/compiler/implementation/resolved_visitor.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a204ccf80c452f35b8daf599ee2052c925754405
--- /dev/null
+++ b/lib/compiler/implementation/resolved_visitor.dart
@@ -0,0 +1,52 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class ResolvedVisitor<R> implements Visitor<R> {
+ TreeElements elements;
+
+ ResolvedVisitor(this.elements);
+
+ R visitSend(Send node) {
+ if (node.isSuperCall) {
+ return visitSuperSend(node);
+ } else if (node.isOperator) {
+ return visitOperatorSend(node);
+ } else if (node.isPropertyAccess) {
+ return visitGetterSend(node);
+ } else if (Elements.isClosureSend(node, elements)) {
+ return visitClosureSend(node);
+ } else {
+ Element element = elements[node];
+ if (element === null) {
+ // Example: f() with 'f' unbound.
+ // This can only happen inside an instance method.
+ return visitDynamicSend(node);
+ } else if (element.kind == ElementKind.CLASS) {
+ internalError("Cannot generate code for send", node: node);
+ } else if (element.isInstanceMember()) {
+ // Example: f() with 'f' bound to instance method.
+ return visitDynamicSend(node);
+ } else if (element.kind === ElementKind.FOREIGN) {
+ return visitForeignSend(node);
+ } 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 visitStaticSend(node);
+ } else {
+ internalError("Cannot generate code for send", node: node);
+ }
+ }
+ }
+
+ abstract R visitSuperSend(Send node);
+ abstract R visitOperatorSend(Send node);
+ abstract R visitGetterSend(Send node);
+ abstract R visitClosureSend(Send node);
+ abstract R visitDynamicSend(Send node);
+ abstract R visitForeignSend(Send node);
+ abstract R visitStaticSend(Send node);
+
+ abstract void internalError(String reason, [Node node]);
+}
« no previous file with comments | « lib/compiler/implementation/leg.dart ('k') | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698