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

Side by Side Diff: dart/frog/leg/tree/nodes.dart

Issue 9634008: Introduce element categories and move resolver towards being more compositional. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/frog/leg/ssa/builder.dart ('k') | dart/frog/leg/warnings.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 interface Visitor<R> { 5 interface Visitor<R> {
6 R visitBlock(Block node); 6 R visitBlock(Block node);
7 R visitBreakStatement(BreakStatement node); 7 R visitBreakStatement(BreakStatement node);
8 R visitCatchBlock(CatchBlock node); 8 R visitCatchBlock(CatchBlock node);
9 R visitClassNode(ClassNode node); 9 R visitClassNode(ClassNode node);
10 R visitConditional(Conditional node); 10 R visitConditional(Conditional node);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 static int _HASH_COUNTER = 0; 73 static int _HASH_COUNTER = 0;
74 74
75 Node() : _hashCode = ++_HASH_COUNTER; 75 Node() : _hashCode = ++_HASH_COUNTER;
76 76
77 hashCode() => _hashCode; 77 hashCode() => _hashCode;
78 78
79 abstract accept(Visitor visitor); 79 abstract accept(Visitor visitor);
80 80
81 abstract visitChildren(Visitor visitor); 81 abstract visitChildren(Visitor visitor);
82 82
83 toString() => unparse(); 83 toString() => unparse(false);
84
85 toDebugString() => unparse(true);
84 86
85 String getObjectDescription() => super.toString(); 87 String getObjectDescription() => super.toString();
86 88
87 String unparse() { 89 String unparse(bool printDebugInfo) {
88 Unparser unparser = new Unparser(); 90 Unparser unparser = new Unparser(printDebugInfo);
89 try { 91 try {
90 return unparser.unparse(this); 92 return unparser.unparse(this);
91 } catch (var e, var trace) { 93 } catch (var e, var trace) {
92 print(trace); 94 print(trace);
93 return '<<unparse error: ${getObjectDescription()}: ${unparser.sb}>>'; 95 return '<<unparse error: ${getObjectDescription()}: ${unparser.sb}>>';
94 } 96 }
95 } 97 }
96 98
97 abstract Token getBeginToken(); 99 abstract Token getBeginToken();
98 100
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 949
948 Token getEndToken() => elements.getEndToken(); 950 Token getEndToken() => elements.getEndToken();
949 } 951 }
950 952
951 class Identifier extends Expression { 953 class Identifier extends Expression {
952 final Token token; 954 final Token token;
953 955
954 SourceString get source() => token.value; 956 SourceString get source() => token.value;
955 957
956 Identifier(Token this.token); 958 Identifier(Token this.token);
957 Identifier.synthetic(String name) : token = new StringToken(null, name, null);
958 959
959 bool isThis() => source.stringValue === 'this'; 960 bool isThis() => source.stringValue === 'this';
960 961
961 bool isSuper() => source.stringValue === 'super'; 962 bool isSuper() => source.stringValue === 'super';
962 963
963 Identifier asIdentifier() => this; 964 Identifier asIdentifier() => this;
964 965
965 accept(Visitor visitor) => visitor.visitIdentifier(this); 966 accept(Visitor visitor) => visitor.visitIdentifier(this);
966 967
967 visitChildren(Visitor visitor) {} 968 visitChildren(Visitor visitor) {}
968 969
969 Token getBeginToken() => token; 970 Token getBeginToken() => token;
970 971
971 Token getEndToken() => token; 972 Token getEndToken() => token;
972 } 973 }
973 974
974 class Operator extends Identifier { 975 class Operator extends Identifier {
975 Operator(Token token) : super(token); 976 Operator(Token token) : super(token);
976 Operator.synthetic(String name) : super.synthetic(name);
977 977
978 Operator asOperator() => this; 978 Operator asOperator() => this;
979 979
980 accept(Visitor visitor) => visitor.visitOperator(this); 980 accept(Visitor visitor) => visitor.visitOperator(this);
981 } 981 }
982 982
983 class Return extends Statement { 983 class Return extends Statement {
984 final Expression expression; 984 final Expression expression;
985 final Token beginToken; 985 final Token beginToken;
986 final Token endToken; 986 final Token endToken;
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 static bool isConstructorRedirect(Send node) { 1702 static bool isConstructorRedirect(Send node) {
1703 return (node.receiver === null && 1703 return (node.receiver === null &&
1704 node.selector.asIdentifier() !== null && 1704 node.selector.asIdentifier() !== null &&
1705 node.selector.asIdentifier().isThis()) || 1705 node.selector.asIdentifier().isThis()) ||
1706 (node.receiver !== null && 1706 (node.receiver !== null &&
1707 node.receiver.asIdentifier() !== null && 1707 node.receiver.asIdentifier() !== null &&
1708 node.receiver.asIdentifier().isThis() && 1708 node.receiver.asIdentifier().isThis() &&
1709 node.selector.asIdentifier() !== null); 1709 node.selector.asIdentifier() !== null);
1710 } 1710 }
1711 } 1711 }
OLDNEW
« no previous file with comments | « dart/frog/leg/ssa/builder.dart ('k') | dart/frog/leg/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698