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

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

Issue 9616058: Implement parsing and resolving of type-variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address 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
OLDNEW
1 // Copyright (c) 2011, 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 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);
11 R visitContinueStatement(ContinueStatement node); 11 R visitContinueStatement(ContinueStatement node);
(...skipping 27 matching lines...) Expand all
39 R visitSend(Send node); 39 R visitSend(Send node);
40 R visitSendSet(SendSet node); 40 R visitSendSet(SendSet node);
41 R visitStringInterpolation(StringInterpolation node); 41 R visitStringInterpolation(StringInterpolation node);
42 R visitStringInterpolationPart(StringInterpolationPart node); 42 R visitStringInterpolationPart(StringInterpolationPart node);
43 R visitSwitchCase(SwitchCase node); 43 R visitSwitchCase(SwitchCase node);
44 R visitSwitchStatement(SwitchStatement node); 44 R visitSwitchStatement(SwitchStatement node);
45 R visitThrow(Throw node); 45 R visitThrow(Throw node);
46 R visitTryStatement(TryStatement node); 46 R visitTryStatement(TryStatement node);
47 R visitTypeAnnotation(TypeAnnotation node); 47 R visitTypeAnnotation(TypeAnnotation node);
48 R visitTypedef(Typedef node); 48 R visitTypedef(Typedef node);
49 R visitTypeVariable(TypeVariable node);
49 R visitVariableDefinitions(VariableDefinitions node); 50 R visitVariableDefinitions(VariableDefinitions node);
50 R visitWhile(While node); 51 R visitWhile(While node);
51 } 52 }
52 53
53 Token firstBeginToken(Node first, Node second) { 54 Token firstBeginToken(Node first, Node second) {
54 if (first !== null) return first.getBeginToken(); 55 if (first !== null) return first.getBeginToken();
55 if (second !== null) return second.getBeginToken(); 56 if (second !== null) return second.getBeginToken();
56 return null; 57 return null;
57 } 58 }
58 59
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 SendSet asSendSet() => null; 136 SendSet asSendSet() => null;
136 Statement asStatement() => null; 137 Statement asStatement() => null;
137 StringInterpolation asStringInterpolation() => null; 138 StringInterpolation asStringInterpolation() => null;
138 StringInterpolationPart asStringInterpolationPart() => null; 139 StringInterpolationPart asStringInterpolationPart() => null;
139 SwitchCase asSwitchCase() => null; 140 SwitchCase asSwitchCase() => null;
140 SwitchStatement asSwitchStatement() => null; 141 SwitchStatement asSwitchStatement() => null;
141 Throw asThrow() => null; 142 Throw asThrow() => null;
142 TryStatement asTryStatement() => null; 143 TryStatement asTryStatement() => null;
143 TypeAnnotation asTypeAnnotation() => null; 144 TypeAnnotation asTypeAnnotation() => null;
144 Typedef asTypedef() => null; 145 Typedef asTypedef() => null;
146 TypeVariable asTypeVariable() => null;
145 VariableDefinitions asVariableDefinitions() => null; 147 VariableDefinitions asVariableDefinitions() => null;
146 While asWhile() => null; 148 While asWhile() => null;
147 149
148 bool isValidBreakTarget() => false; 150 bool isValidBreakTarget() => false;
149 bool isValidContinueTarget() => false; 151 bool isValidContinueTarget() => false;
150 } 152 }
151 153
152 class ClassNode extends Node { 154 class ClassNode extends Node {
153 final Identifier name; 155 final Identifier name;
154 final TypeAnnotation superclass; 156 final TypeAnnotation superclass;
155 final NodeList interfaces; 157 final NodeList interfaces;
158 final NodeList typeParameters;
156 159
157 // Using a NodeList to record the keyword "default". 160 // Using a NodeList to record the keyword "default".
158 // TODO(ahe): Consider if there is a better way to represent this. 161 // TODO(ahe): Consider if there is a better way to represent this.
159 final NodeList defaultClause; 162 final NodeList defaultClause;
160 163
161 final Token beginToken; 164 final Token beginToken;
162 final Token extendsKeyword; 165 final Token extendsKeyword;
163 final Token endToken; 166 final Token endToken;
164 167
165 ClassNode(this.name, this.superclass, this.interfaces, this.defaultClause, 168 ClassNode(this.name, this.typeParameters, this.superclass, this.interfaces,
166 this.beginToken, this.extendsKeyword, this.endToken); 169 this.defaultClause, this.beginToken, this.extendsKeyword,
170 this.endToken);
167 171
168 ClassNode asClassNode() => this; 172 ClassNode asClassNode() => this;
169 173
170 accept(Visitor visitor) => visitor.visitClassNode(this); 174 accept(Visitor visitor) => visitor.visitClassNode(this);
171 175
172 visitChildren(Visitor visitor) { 176 visitChildren(Visitor visitor) {
173 if (name !== null) name.accept(visitor); 177 if (name !== null) name.accept(visitor);
174 if (superclass !== null) superclass.accept(visitor); 178 if (superclass !== null) superclass.accept(visitor);
175 if (interfaces !== null) interfaces.accept(visitor); 179 if (interfaces !== null) interfaces.accept(visitor);
176 } 180 }
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 visitChildren(Visitor visitor) { 1067 visitChildren(Visitor visitor) {
1064 typeName.accept(visitor); 1068 typeName.accept(visitor);
1065 if (typeArguments !== null) typeArguments.accept(visitor); 1069 if (typeArguments !== null) typeArguments.accept(visitor);
1066 } 1070 }
1067 1071
1068 Token getBeginToken() => typeName.getBeginToken(); 1072 Token getBeginToken() => typeName.getBeginToken();
1069 1073
1070 Token getEndToken() => typeName.getEndToken(); 1074 Token getEndToken() => typeName.getEndToken();
1071 } 1075 }
1072 1076
1077 class TypeVariable extends Node {
1078 final Identifier name;
1079 final TypeAnnotation bound;
1080 TypeVariable(Identifier this.name, TypeAnnotation this.bound);
1081
1082 accept(Visitor visitor) => visitor.visitTypeVariable(this);
1083
1084 visitChildren(Visitor visitor) {
1085 name.accept(visitor);
1086 if (bound !== null) {
1087 bound.accept(visitor);
1088 }
1089 }
1090
1091 TypeVariable asTypeVariable() => this;
1092
1093 Token getBeginToken() => name.getBeginToken();
1094
1095 Token getEndToken() {
1096 return (bound !== null) ? bound.getEndToken() : name.getEndToken();
1097 }
1098 }
1099
1073 class VariableDefinitions extends Statement { 1100 class VariableDefinitions extends Statement {
1074 final Token endToken; 1101 final Token endToken;
1075 final TypeAnnotation type; 1102 final TypeAnnotation type;
1076 final Modifiers modifiers; 1103 final Modifiers modifiers;
1077 final NodeList definitions; 1104 final NodeList definitions;
1078 VariableDefinitions(this.type, this.modifiers, this.definitions, 1105 VariableDefinitions(this.type, this.modifiers, this.definitions,
1079 this.endToken); 1106 this.endToken);
1080 1107
1081 VariableDefinitions asVariableDefinitions() => this; 1108 VariableDefinitions asVariableDefinitions() => this;
1082 1109
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 static bool isConstructorRedirect(Send node) { 1735 static bool isConstructorRedirect(Send node) {
1709 return (node.receiver === null && 1736 return (node.receiver === null &&
1710 node.selector.asIdentifier() !== null && 1737 node.selector.asIdentifier() !== null &&
1711 node.selector.asIdentifier().isThis()) || 1738 node.selector.asIdentifier().isThis()) ||
1712 (node.receiver !== null && 1739 (node.receiver !== null &&
1713 node.receiver.asIdentifier() !== null && 1740 node.receiver.asIdentifier() !== null &&
1714 node.receiver.asIdentifier().isThis() && 1741 node.receiver.asIdentifier().isThis() &&
1715 node.selector.asIdentifier() !== null); 1742 node.selector.asIdentifier() !== null);
1716 } 1743 }
1717 } 1744 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698