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

Side by Side Diff: lib/compiler/implementation/resolved_visitor.dart

Issue 10942028: Support class and typedef literals as expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Peter's comments. Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart2js; 5 part of dart2js;
6 6
7 abstract class ResolvedVisitor<R> extends Visitor<R> { 7 abstract class ResolvedVisitor<R> extends Visitor<R> {
8 TreeElements elements; 8 TreeElements elements;
9 9
10 ResolvedVisitor(this.elements); 10 ResolvedVisitor(this.elements);
11 11
12 R visitSend(Send node) { 12 R visitSend(Send node) {
13 if (node.isSuperCall) { 13 if (node.isSuperCall) {
14 return visitSuperSend(node); 14 return visitSuperSend(node);
15 } else if (node.isOperator) { 15 } else if (node.isOperator) {
16 return visitOperatorSend(node); 16 return visitOperatorSend(node);
17 } else if (node.isPropertyAccess) { 17 } else if (node.isPropertyAccess) {
18 return visitGetterSend(node); 18 Element element = elements[node];
19 if (!Elements.isUnresolved(element) && element.impliesType()) {
20 // A reference to a class literal, typedef or type variable.
21 return visitTypeReferenceSend(node);
22 } else {
23 return visitGetterSend(node);
24 }
19 } else if (Elements.isClosureSend(node, elements[node])) { 25 } else if (Elements.isClosureSend(node, elements[node])) {
20 return visitClosureSend(node); 26 return visitClosureSend(node);
21 } else { 27 } else {
22 Element element = elements[node]; 28 Element element = elements[node];
23 if (Elements.isUnresolved(element)) { 29 if (Elements.isUnresolved(element)) {
24 if (element == null) { 30 if (element == null) {
25 // Example: f() with 'f' unbound. 31 // Example: f() with 'f' unbound.
26 // This can only happen inside an instance method. 32 // This can only happen inside an instance method.
27 return visitDynamicSend(node); 33 return visitDynamicSend(node);
28 } else { 34 } else {
29 return visitStaticSend(node); 35 return visitStaticSend(node);
30 } 36 }
31 } else if (element.kind == ElementKind.CLASS) { 37 } else if (element.impliesType()) {
32 internalError("Cannot generate code for send", node: node); 38 // A reference to a class literal, typedef or type variable.
39 return visitTypeReferenceSend(node);
33 } else if (element.isInstanceMember()) { 40 } else if (element.isInstanceMember()) {
34 // Example: f() with 'f' bound to instance method. 41 // Example: f() with 'f' bound to instance method.
35 return visitDynamicSend(node); 42 return visitDynamicSend(node);
36 } else if (identical(element.kind, ElementKind.FOREIGN)) { 43 } else if (identical(element.kind, ElementKind.FOREIGN)) {
37 return visitForeignSend(node); 44 return visitForeignSend(node);
38 } else if (!element.isInstanceMember()) { 45 } else if (!element.isInstanceMember()) {
39 // Example: A.f() or f() with 'f' bound to a static function. 46 // Example: A.f() or f() with 'f' bound to a static function.
40 // Also includes new A() or new A.named() which is treated like a 47 // Also includes new A() or new A.named() which is treated like a
41 // static call to a factory. 48 // static call to a factory.
42 return visitStaticSend(node); 49 return visitStaticSend(node);
43 } else { 50 } else {
44 internalError("Cannot generate code for send", node: node); 51 internalError("Cannot generate code for send", node: node);
45 } 52 }
46 } 53 }
47 } 54 }
48 55
49 abstract R visitSuperSend(Send node); 56 abstract R visitSuperSend(Send node);
50 abstract R visitOperatorSend(Send node); 57 abstract R visitOperatorSend(Send node);
51 abstract R visitGetterSend(Send node); 58 abstract R visitGetterSend(Send node);
52 abstract R visitClosureSend(Send node); 59 abstract R visitClosureSend(Send node);
53 abstract R visitDynamicSend(Send node); 60 abstract R visitDynamicSend(Send node);
54 abstract R visitForeignSend(Send node); 61 abstract R visitForeignSend(Send node);
55 abstract R visitStaticSend(Send node); 62 abstract R visitStaticSend(Send node);
63 abstract R visitTypeReferenceSend(Send node);
56 64
57 abstract void internalError(String reason, {Node node}); 65 abstract void internalError(String reason, {Node node});
58 66
59 R visitNode(Node node) { 67 R visitNode(Node node) {
60 internalError("Unhandled node", node: node); 68 internalError("Unhandled node", node: node);
61 } 69 }
62 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698