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

Side by Side Diff: pkg/compiler/lib/src/tree/nodes.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « pkg/compiler/lib/src/tree/dartstring.dart ('k') | pkg/compiler/lib/src/tree/prettyprint.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) 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 import 'dart:collection' show IterableMixin; 5 import 'dart:collection' show IterableMixin;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../tokens/precedence_constants.dart' as Precedence show FUNCTION_INFO; 8 import '../tokens/precedence_constants.dart' as Precedence show FUNCTION_INFO;
9 import '../tokens/token.dart' show BeginGroupToken, Token; 9 import '../tokens/token.dart' show BeginGroupToken, Token;
10 import '../tokens/token_constants.dart' as Tokens show IDENTIFIER_TOKEN, KEYWORD _TOKEN, PLUS_TOKEN; 10 import '../tokens/token_constants.dart' as Tokens
11 show IDENTIFIER_TOKEN, KEYWORD_TOKEN, PLUS_TOKEN;
11 import '../util/util.dart'; 12 import '../util/util.dart';
12 import '../util/characters.dart'; 13 import '../util/characters.dart';
13 import '../resolution/secret_tree_element.dart' show NullTreeElementMixin, Store dTreeElementMixin; 14 import '../resolution/secret_tree_element.dart'
15 show NullTreeElementMixin, StoredTreeElementMixin;
14 import '../elements/elements.dart' show MetadataAnnotation; 16 import '../elements/elements.dart' show MetadataAnnotation;
15 import 'dartstring.dart'; 17 import 'dartstring.dart';
16 import 'prettyprint.dart'; 18 import 'prettyprint.dart';
17 import 'unparser.dart'; 19 import 'unparser.dart';
18 20
19 abstract class Visitor<R> { 21 abstract class Visitor<R> {
20 const Visitor(); 22 const Visitor();
21 23
22 R visitNode(Node node); 24 R visitNode(Node node);
23 25
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 R visitStringJuxtaposition(StringJuxtaposition node) => visitStringNode(node); 69 R visitStringJuxtaposition(StringJuxtaposition node) => visitStringNode(node);
68 R visitSyncForIn(SyncForIn node) => visitLoop(node); 70 R visitSyncForIn(SyncForIn node) => visitLoop(node);
69 R visitLoop(Loop node) => visitStatement(node); 71 R visitLoop(Loop node) => visitStatement(node);
70 R visitMetadata(Metadata node) => visitNode(node); 72 R visitMetadata(Metadata node) => visitNode(node);
71 R visitMixinApplication(MixinApplication node) => visitNode(node); 73 R visitMixinApplication(MixinApplication node) => visitNode(node);
72 R visitModifiers(Modifiers node) => visitNode(node); 74 R visitModifiers(Modifiers node) => visitNode(node);
73 R visitNamedArgument(NamedArgument node) => visitExpression(node); 75 R visitNamedArgument(NamedArgument node) => visitExpression(node);
74 R visitNamedMixinApplication(NamedMixinApplication node) { 76 R visitNamedMixinApplication(NamedMixinApplication node) {
75 return visitMixinApplication(node); 77 return visitMixinApplication(node);
76 } 78 }
79
77 R visitNewExpression(NewExpression node) => visitExpression(node); 80 R visitNewExpression(NewExpression node) => visitExpression(node);
78 R visitNodeList(NodeList node) => visitNode(node); 81 R visitNodeList(NodeList node) => visitNode(node);
79 R visitOperator(Operator node) => visitIdentifier(node); 82 R visitOperator(Operator node) => visitIdentifier(node);
80 R visitParenthesizedExpression(ParenthesizedExpression node) { 83 R visitParenthesizedExpression(ParenthesizedExpression node) {
81 return visitExpression(node); 84 return visitExpression(node);
82 } 85 }
86
83 R visitPart(Part node) => visitLibraryTag(node); 87 R visitPart(Part node) => visitLibraryTag(node);
84 R visitPartOf(PartOf node) => visitNode(node); 88 R visitPartOf(PartOf node) => visitNode(node);
85 R visitPostfix(Postfix node) => visitNodeList(node); 89 R visitPostfix(Postfix node) => visitNodeList(node);
86 R visitPrefix(Prefix node) => visitNodeList(node); 90 R visitPrefix(Prefix node) => visitNodeList(node);
87 R visitRedirectingFactoryBody(RedirectingFactoryBody node) { 91 R visitRedirectingFactoryBody(RedirectingFactoryBody node) {
88 return visitStatement(node); 92 return visitStatement(node);
89 } 93 }
94
90 R visitRethrow(Rethrow node) => visitStatement(node); 95 R visitRethrow(Rethrow node) => visitStatement(node);
91 R visitReturn(Return node) => visitStatement(node); 96 R visitReturn(Return node) => visitStatement(node);
92 R visitSend(Send node) => visitExpression(node); 97 R visitSend(Send node) => visitExpression(node);
93 R visitSendSet(SendSet node) => visitSend(node); 98 R visitSendSet(SendSet node) => visitSend(node);
94 R visitStatement(Statement node) => visitNode(node); 99 R visitStatement(Statement node) => visitNode(node);
95 R visitStringNode(StringNode node) => visitExpression(node); 100 R visitStringNode(StringNode node) => visitExpression(node);
96 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node); 101 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node);
97 R visitStringInterpolationPart(StringInterpolationPart node) { 102 R visitStringInterpolationPart(StringInterpolationPart node) {
98 return visitNode(node); 103 return visitNode(node);
99 } 104 }
105
100 R visitSwitchCase(SwitchCase node) => visitNode(node); 106 R visitSwitchCase(SwitchCase node) => visitNode(node);
101 R visitSwitchStatement(SwitchStatement node) => visitStatement(node); 107 R visitSwitchStatement(SwitchStatement node) => visitStatement(node);
102 R visitLiteralSymbol(LiteralSymbol node) => visitExpression(node); 108 R visitLiteralSymbol(LiteralSymbol node) => visitExpression(node);
103 R visitThrow(Throw node) => visitExpression(node); 109 R visitThrow(Throw node) => visitExpression(node);
104 R visitTryStatement(TryStatement node) => visitStatement(node); 110 R visitTryStatement(TryStatement node) => visitStatement(node);
105 R visitTypeAnnotation(TypeAnnotation node) => visitNode(node); 111 R visitTypeAnnotation(TypeAnnotation node) => visitNode(node);
106 R visitTypedef(Typedef node) => visitNode(node); 112 R visitTypedef(Typedef node) => visitNode(node);
107 R visitTypeVariable(TypeVariable node) => visitNode(node); 113 R visitTypeVariable(TypeVariable node) => visitNode(node);
108 R visitVariableDefinitions(VariableDefinitions node) => visitStatement(node); 114 R visitVariableDefinitions(VariableDefinitions node) => visitStatement(node);
109 R visitWhile(While node) => visitLoop(node); 115 R visitWhile(While node) => visitLoop(node);
110 R visitYield(Yield node) => visitStatement(node); 116 R visitYield(Yield node) => visitStatement(node);
111 } 117 }
112 118
113 /// Visitor for [Node]s that take an additional argument of type [A] and returns 119 /// Visitor for [Node]s that take an additional argument of type [A] and returns
114 /// a value of type [R]. 120 /// a value of type [R].
115 abstract class Visitor1<R, A> { 121 abstract class Visitor1<R, A> {
116 const Visitor1(); 122 const Visitor1();
117 123
118 R visitNode(Node node, A arg); 124 R visitNode(Node node, A arg);
119 125
120 R visitAssert(Assert node, A arg) => visitStatement(node, arg); 126 R visitAssert(Assert node, A arg) => visitStatement(node, arg);
121 R visitAsyncForIn(AsyncForIn node, A arg) => visitLoop(node, arg); 127 R visitAsyncForIn(AsyncForIn node, A arg) => visitLoop(node, arg);
122 R visitAsyncModifier(AsyncModifier node, A arg) => visitNode(node, arg); 128 R visitAsyncModifier(AsyncModifier node, A arg) => visitNode(node, arg);
123 R visitAwait(Await node, A arg) => visitExpression(node, arg); 129 R visitAwait(Await node, A arg) => visitExpression(node, arg);
124 R visitBlock(Block node, A arg) => visitStatement(node, arg); 130 R visitBlock(Block node, A arg) => visitStatement(node, arg);
125 R visitBreakStatement(BreakStatement node, A arg) { 131 R visitBreakStatement(BreakStatement node, A arg) {
126 return visitGotoStatement(node, arg); 132 return visitGotoStatement(node, arg);
127 } 133 }
134
128 R visitCascade(Cascade node, A arg) => visitExpression(node, arg); 135 R visitCascade(Cascade node, A arg) => visitExpression(node, arg);
129 R visitCascadeReceiver(CascadeReceiver node, A arg) { 136 R visitCascadeReceiver(CascadeReceiver node, A arg) {
130 return visitExpression(node, arg); 137 return visitExpression(node, arg);
131 } 138 }
139
132 R visitCaseMatch(CaseMatch node, A arg) => visitNode(node, arg); 140 R visitCaseMatch(CaseMatch node, A arg) => visitNode(node, arg);
133 R visitCatchBlock(CatchBlock node, A arg) => visitNode(node, arg); 141 R visitCatchBlock(CatchBlock node, A arg) => visitNode(node, arg);
134 R visitClassNode(ClassNode node, A arg) => visitNode(node, arg); 142 R visitClassNode(ClassNode node, A arg) => visitNode(node, arg);
135 R visitCombinator(Combinator node, A arg) => visitNode(node, arg); 143 R visitCombinator(Combinator node, A arg) => visitNode(node, arg);
136 R visitConditional(Conditional node, A arg) => visitExpression(node, arg); 144 R visitConditional(Conditional node, A arg) => visitExpression(node, arg);
137 R visitConditionalUri(ConditionalUri node, A arg) { 145 R visitConditionalUri(ConditionalUri node, A arg) {
138 return visitNode(node, arg); 146 return visitNode(node, arg);
139 } 147 }
148
140 R visitContinueStatement(ContinueStatement node, A arg) { 149 R visitContinueStatement(ContinueStatement node, A arg) {
141 return visitGotoStatement(node, arg); 150 return visitGotoStatement(node, arg);
142 } 151 }
152
143 R visitDottedName(DottedName node, A arg) { 153 R visitDottedName(DottedName node, A arg) {
144 return visitExpression(node, arg); 154 return visitExpression(node, arg);
145 } 155 }
156
146 R visitDoWhile(DoWhile node, A arg) => visitLoop(node, arg); 157 R visitDoWhile(DoWhile node, A arg) => visitLoop(node, arg);
147 R visitEmptyStatement(EmptyStatement node, A arg) { 158 R visitEmptyStatement(EmptyStatement node, A arg) {
148 return visitStatement(node, arg); 159 return visitStatement(node, arg);
149 } 160 }
161
150 R visitEnum(Enum node, A arg) => visitNode(node, arg); 162 R visitEnum(Enum node, A arg) => visitNode(node, arg);
151 R visitExport(Export node, A arg) => visitLibraryDependency(node, arg); 163 R visitExport(Export node, A arg) => visitLibraryDependency(node, arg);
152 R visitExpression(Expression node, A arg) => visitNode(node, arg); 164 R visitExpression(Expression node, A arg) => visitNode(node, arg);
153 R visitExpressionStatement(ExpressionStatement node, A arg) { 165 R visitExpressionStatement(ExpressionStatement node, A arg) {
154 return visitStatement(node, arg); 166 return visitStatement(node, arg);
155 } 167 }
168
156 R visitFor(For node, A arg) => visitLoop(node, arg); 169 R visitFor(For node, A arg) => visitLoop(node, arg);
157 R visitFunctionDeclaration(FunctionDeclaration node, A arg) { 170 R visitFunctionDeclaration(FunctionDeclaration node, A arg) {
158 return visitStatement(node, arg); 171 return visitStatement(node, arg);
159 } 172 }
173
160 R visitFunctionExpression(FunctionExpression node, A arg) { 174 R visitFunctionExpression(FunctionExpression node, A arg) {
161 return visitExpression(node, arg); 175 return visitExpression(node, arg);
162 } 176 }
177
163 R visitGotoStatement(GotoStatement node, A arg) { 178 R visitGotoStatement(GotoStatement node, A arg) {
164 return visitStatement(node, arg); 179 return visitStatement(node, arg);
165 } 180 }
181
166 R visitIdentifier(Identifier node, A arg) { 182 R visitIdentifier(Identifier node, A arg) {
167 return visitExpression(node, arg); 183 return visitExpression(node, arg);
168 } 184 }
185
169 R visitImport(Import node, A arg) { 186 R visitImport(Import node, A arg) {
170 return visitLibraryDependency(node, arg); 187 return visitLibraryDependency(node, arg);
171 } 188 }
189
172 R visitIf(If node, A arg) => visitStatement(node, arg); 190 R visitIf(If node, A arg) => visitStatement(node, arg);
173 R visitLabel(Label node, A arg) => visitNode(node, arg); 191 R visitLabel(Label node, A arg) => visitNode(node, arg);
174 R visitLabeledStatement(LabeledStatement node, A arg) { 192 R visitLabeledStatement(LabeledStatement node, A arg) {
175 return visitStatement(node, arg); 193 return visitStatement(node, arg);
176 } 194 }
195
177 R visitLibraryDependency(LibraryDependency node, A arg) { 196 R visitLibraryDependency(LibraryDependency node, A arg) {
178 return visitLibraryTag(node, arg); 197 return visitLibraryTag(node, arg);
179 } 198 }
199
180 R visitLibraryName(LibraryName node, A arg) => visitLibraryTag(node, arg); 200 R visitLibraryName(LibraryName node, A arg) => visitLibraryTag(node, arg);
181 R visitLibraryTag(LibraryTag node, A arg) => visitNode(node, arg); 201 R visitLibraryTag(LibraryTag node, A arg) => visitNode(node, arg);
182 R visitLiteral(Literal node, A arg) => visitExpression(node, arg); 202 R visitLiteral(Literal node, A arg) => visitExpression(node, arg);
183 R visitLiteralBool(LiteralBool node, A arg) => visitLiteral(node, arg); 203 R visitLiteralBool(LiteralBool node, A arg) => visitLiteral(node, arg);
184 R visitLiteralDouble(LiteralDouble node, A arg) => visitLiteral(node, arg); 204 R visitLiteralDouble(LiteralDouble node, A arg) => visitLiteral(node, arg);
185 R visitLiteralInt(LiteralInt node, A arg) => visitLiteral(node, arg); 205 R visitLiteralInt(LiteralInt node, A arg) => visitLiteral(node, arg);
186 R visitLiteralList(LiteralList node, A arg) => visitExpression(node, arg); 206 R visitLiteralList(LiteralList node, A arg) => visitExpression(node, arg);
187 R visitLiteralMap(LiteralMap node, A arg) => visitExpression(node, arg); 207 R visitLiteralMap(LiteralMap node, A arg) => visitExpression(node, arg);
188 R visitLiteralMapEntry(LiteralMapEntry node, A arg) => visitNode(node, arg); 208 R visitLiteralMapEntry(LiteralMapEntry node, A arg) => visitNode(node, arg);
189 R visitLiteralNull(LiteralNull node, A arg) => visitLiteral(node, arg); 209 R visitLiteralNull(LiteralNull node, A arg) => visitLiteral(node, arg);
190 R visitLiteralString(LiteralString node, A arg) => visitStringNode(node, arg); 210 R visitLiteralString(LiteralString node, A arg) => visitStringNode(node, arg);
191 R visitStringJuxtaposition(StringJuxtaposition node, A arg) { 211 R visitStringJuxtaposition(StringJuxtaposition node, A arg) {
192 return visitStringNode(node, arg); 212 return visitStringNode(node, arg);
193 } 213 }
214
194 R visitSyncForIn(SyncForIn node, A arg) => visitLoop(node, arg); 215 R visitSyncForIn(SyncForIn node, A arg) => visitLoop(node, arg);
195 R visitLoop(Loop node, A arg) => visitStatement(node, arg); 216 R visitLoop(Loop node, A arg) => visitStatement(node, arg);
196 R visitMetadata(Metadata node, A arg) => visitNode(node, arg); 217 R visitMetadata(Metadata node, A arg) => visitNode(node, arg);
197 R visitMixinApplication(MixinApplication node, A arg) => visitNode(node, arg); 218 R visitMixinApplication(MixinApplication node, A arg) => visitNode(node, arg);
198 R visitModifiers(Modifiers node, A arg) => visitNode(node, arg); 219 R visitModifiers(Modifiers node, A arg) => visitNode(node, arg);
199 R visitNamedArgument(NamedArgument node, A arg) => visitExpression(node, arg); 220 R visitNamedArgument(NamedArgument node, A arg) => visitExpression(node, arg);
200 R visitNamedMixinApplication(NamedMixinApplication node, A arg) { 221 R visitNamedMixinApplication(NamedMixinApplication node, A arg) {
201 return visitMixinApplication(node, arg); 222 return visitMixinApplication(node, arg);
202 } 223 }
224
203 R visitNewExpression(NewExpression node, A arg) => visitExpression(node, arg); 225 R visitNewExpression(NewExpression node, A arg) => visitExpression(node, arg);
204 R visitNodeList(NodeList node, A arg) => visitNode(node, arg); 226 R visitNodeList(NodeList node, A arg) => visitNode(node, arg);
205 R visitOperator(Operator node, A arg) => visitIdentifier(node, arg); 227 R visitOperator(Operator node, A arg) => visitIdentifier(node, arg);
206 R visitParenthesizedExpression(ParenthesizedExpression node, A arg) { 228 R visitParenthesizedExpression(ParenthesizedExpression node, A arg) {
207 return visitExpression(node, arg); 229 return visitExpression(node, arg);
208 } 230 }
231
209 R visitPart(Part node, A arg) => visitLibraryTag(node, arg); 232 R visitPart(Part node, A arg) => visitLibraryTag(node, arg);
210 R visitPartOf(PartOf node, A arg) => visitNode(node, arg); 233 R visitPartOf(PartOf node, A arg) => visitNode(node, arg);
211 R visitPostfix(Postfix node, A arg) => visitNodeList(node, arg); 234 R visitPostfix(Postfix node, A arg) => visitNodeList(node, arg);
212 R visitPrefix(Prefix node, A arg) => visitNodeList(node, arg); 235 R visitPrefix(Prefix node, A arg) => visitNodeList(node, arg);
213 R visitRedirectingFactoryBody(RedirectingFactoryBody node, A arg) { 236 R visitRedirectingFactoryBody(RedirectingFactoryBody node, A arg) {
214 return visitStatement(node, arg); 237 return visitStatement(node, arg);
215 } 238 }
239
216 R visitRethrow(Rethrow node, A arg) => visitStatement(node, arg); 240 R visitRethrow(Rethrow node, A arg) => visitStatement(node, arg);
217 R visitReturn(Return node, A arg) => visitStatement(node, arg); 241 R visitReturn(Return node, A arg) => visitStatement(node, arg);
218 R visitSend(Send node, A arg) => visitExpression(node, arg); 242 R visitSend(Send node, A arg) => visitExpression(node, arg);
219 R visitSendSet(SendSet node, A arg) => visitSend(node, arg); 243 R visitSendSet(SendSet node, A arg) => visitSend(node, arg);
220 R visitStatement(Statement node, A arg) => visitNode(node, arg); 244 R visitStatement(Statement node, A arg) => visitNode(node, arg);
221 R visitStringNode(StringNode node, A arg) => visitExpression(node, arg); 245 R visitStringNode(StringNode node, A arg) => visitExpression(node, arg);
222 R visitStringInterpolation(StringInterpolation node, A arg) { 246 R visitStringInterpolation(StringInterpolation node, A arg) {
223 return visitStringNode(node, arg); 247 return visitStringNode(node, arg);
224 } 248 }
249
225 R visitStringInterpolationPart(StringInterpolationPart node, A arg) { 250 R visitStringInterpolationPart(StringInterpolationPart node, A arg) {
226 return visitNode(node, arg); 251 return visitNode(node, arg);
227 } 252 }
253
228 R visitSwitchCase(SwitchCase node, A arg) => visitNode(node, arg); 254 R visitSwitchCase(SwitchCase node, A arg) => visitNode(node, arg);
229 R visitSwitchStatement(SwitchStatement node, A arg) { 255 R visitSwitchStatement(SwitchStatement node, A arg) {
230 return visitStatement(node, arg); 256 return visitStatement(node, arg);
231 } 257 }
258
232 R visitLiteralSymbol(LiteralSymbol node, A arg) => visitExpression(node, arg); 259 R visitLiteralSymbol(LiteralSymbol node, A arg) => visitExpression(node, arg);
233 R visitThrow(Throw node, A arg) => visitExpression(node, arg); 260 R visitThrow(Throw node, A arg) => visitExpression(node, arg);
234 R visitTryStatement(TryStatement node, A arg) => visitStatement(node, arg); 261 R visitTryStatement(TryStatement node, A arg) => visitStatement(node, arg);
235 R visitTypeAnnotation(TypeAnnotation node, A arg) => visitNode(node, arg); 262 R visitTypeAnnotation(TypeAnnotation node, A arg) => visitNode(node, arg);
236 R visitTypedef(Typedef node, A arg) => visitNode(node, arg); 263 R visitTypedef(Typedef node, A arg) => visitNode(node, arg);
237 R visitTypeVariable(TypeVariable node, A arg) => visitNode(node, arg); 264 R visitTypeVariable(TypeVariable node, A arg) => visitNode(node, arg);
238 R visitVariableDefinitions(VariableDefinitions node, A arg) { 265 R visitVariableDefinitions(VariableDefinitions node, A arg) {
239 return visitStatement(node, arg); 266 return visitStatement(node, arg);
240 } 267 }
268
241 R visitWhile(While node, A arg) => visitLoop(node, arg); 269 R visitWhile(While node, A arg) => visitLoop(node, arg);
242 R visitYield(Yield node, A arg) => visitStatement(node, arg); 270 R visitYield(Yield node, A arg) => visitStatement(node, arg);
243 } 271 }
244 272
245
246 Token firstBeginToken(Node first, Node second) { 273 Token firstBeginToken(Node first, Node second) {
247 Token token = null; 274 Token token = null;
248 if (first != null) { 275 if (first != null) {
249 token = first.getBeginToken(); 276 token = first.getBeginToken();
250 } 277 }
251 if (token == null && second != null) { 278 if (token == null && second != null) {
252 // [token] might be null even when [first] is not, e.g. for empty Modifiers. 279 // [token] might be null even when [first] is not, e.g. for empty Modifiers.
253 token = second.getBeginToken(); 280 token = second.getBeginToken();
254 } 281 }
255 return token; 282 return token;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 final Identifier name; 420 final Identifier name;
394 final Node superclass; 421 final Node superclass;
395 final NodeList interfaces; 422 final NodeList interfaces;
396 final NodeList typeParameters; 423 final NodeList typeParameters;
397 final NodeList body; 424 final NodeList body;
398 425
399 final Token beginToken; 426 final Token beginToken;
400 final Token extendsKeyword; 427 final Token extendsKeyword;
401 final Token endToken; 428 final Token endToken;
402 429
403 ClassNode(this.modifiers, this.name, this.typeParameters, this.superclass, 430 ClassNode(
404 this.interfaces, this.beginToken, 431 this.modifiers,
405 this.extendsKeyword, this.body, this.endToken); 432 this.name,
433 this.typeParameters,
434 this.superclass,
435 this.interfaces,
436 this.beginToken,
437 this.extendsKeyword,
438 this.body,
439 this.endToken);
406 440
407 ClassNode asClassNode() => this; 441 ClassNode asClassNode() => this;
408 442
409 accept(Visitor visitor) => visitor.visitClassNode(this); 443 accept(Visitor visitor) => visitor.visitClassNode(this);
410 444
411 accept1(Visitor1 visitor, arg) => visitor.visitClassNode(this, arg); 445 accept1(Visitor1 visitor, arg) => visitor.visitClassNode(this, arg);
412 446
413 visitChildren(Visitor visitor) { 447 visitChildren(Visitor visitor) {
414 if (name != null) name.accept(visitor); 448 if (name != null) name.accept(visitor);
415 if (typeParameters != null) typeParameters.accept(visitor); 449 if (typeParameters != null) typeParameters.accept(visitor);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 final Identifier name; 516 final Identifier name;
483 final NodeList typeParameters; 517 final NodeList typeParameters;
484 518
485 final Modifiers modifiers; 519 final Modifiers modifiers;
486 final MixinApplication mixinApplication; 520 final MixinApplication mixinApplication;
487 final NodeList interfaces; 521 final NodeList interfaces;
488 522
489 final Token classKeyword; 523 final Token classKeyword;
490 final Token endToken; 524 final Token endToken;
491 525
492 NamedMixinApplication(this.name, this.typeParameters, 526 NamedMixinApplication(this.name, this.typeParameters, this.modifiers,
493 this.modifiers, this.mixinApplication, this.interfaces, 527 this.mixinApplication, this.interfaces, this.classKeyword, this.endToken);
494 this.classKeyword, this.endToken);
495 528
496 TypeAnnotation get superclass => mixinApplication.superclass; 529 TypeAnnotation get superclass => mixinApplication.superclass;
497 NodeList get mixins => mixinApplication.mixins; 530 NodeList get mixins => mixinApplication.mixins;
498 531
499 MixinApplication asMixinApplication() => this; 532 MixinApplication asMixinApplication() => this;
500 NamedMixinApplication asNamedMixinApplication() => this; 533 NamedMixinApplication asNamedMixinApplication() => this;
501 534
502 accept(Visitor visitor) => visitor.visitNamedMixinApplication(this); 535 accept(Visitor visitor) => visitor.visitNamedMixinApplication(this);
503 536
504 accept1(Visitor1 visitor, arg) { 537 accept1(Visitor1 visitor, arg) {
(...skipping 29 matching lines...) Expand all
534 abstract class Statement extends Node { 567 abstract class Statement extends Node {
535 Statement(); 568 Statement();
536 569
537 Statement asStatement() => this; 570 Statement asStatement() => this;
538 571
539 bool isValidBreakTarget() => true; 572 bool isValidBreakTarget() => true;
540 } 573 }
541 574
542 /// Erroneous expression that behaves as a literal null. 575 /// Erroneous expression that behaves as a literal null.
543 class ErrorExpression extends LiteralNull { 576 class ErrorExpression extends LiteralNull {
544 ErrorExpression(token) 577 ErrorExpression(token) : super(token);
545 : super(token);
546 578
547 ErrorExpression asErrorExpression() => this; 579 ErrorExpression asErrorExpression() => this;
548 580
549 bool get isErroneous => true; 581 bool get isErroneous => true;
550 } 582 }
551 583
552 /** 584 /**
553 * A message send aka method invocation. In Dart, most operations can 585 * A message send aka method invocation. In Dart, most operations can
554 * (and should) be considered as message sends. Getters and setters 586 * (and should) be considered as message sends. Getters and setters
555 * are just methods with a special syntax. Consequently, we model 587 * are just methods with a special syntax. Consequently, we model
556 * property access, assignment, operators, and method calls with this 588 * property access, assignment, operators, and method calls with this
557 * one node. 589 * one node.
558 */ 590 */
559 class Send extends Expression with StoredTreeElementMixin { 591 class Send extends Expression with StoredTreeElementMixin {
560 final Node receiver; 592 final Node receiver;
561 final Node selector; 593 final Node selector;
562 final NodeList argumentsNode; 594 final NodeList argumentsNode;
563 595
564 /// Whether this is a conditinal send of the form `a?.b`. 596 /// Whether this is a conditinal send of the form `a?.b`.
565 final bool isConditional; 597 final bool isConditional;
566 598
567 Link<Node> get arguments => argumentsNode.nodes; 599 Link<Node> get arguments => argumentsNode.nodes;
568 600
569 Send([this.receiver, this.selector, this.argumentsNode, 601 Send(
602 [this.receiver,
603 this.selector,
604 this.argumentsNode,
570 this.isConditional = false]); 605 this.isConditional = false]);
571 Send.postfix(this.receiver, this.selector, 606 Send.postfix(this.receiver, this.selector,
572 [Node argument = null, this.isConditional = false]) 607 [Node argument = null, this.isConditional = false])
573 : argumentsNode = (argument == null) 608 : argumentsNode = (argument == null)
574 ? new Postfix() 609 ? new Postfix()
575 : new Postfix.singleton(argument); 610 : new Postfix.singleton(argument);
576 Send.prefix(this.receiver, this.selector, 611 Send.prefix(this.receiver, this.selector,
577 [Node argument = null, this.isConditional = false]) 612 [Node argument = null, this.isConditional = false])
578 : argumentsNode = (argument == null) 613 : argumentsNode =
579 ? new Prefix() 614 (argument == null) ? new Prefix() : new Prefix.singleton(argument);
580 : new Prefix.singleton(argument);
581 615
582 Send asSend() => this; 616 Send asSend() => this;
583 617
584 accept(Visitor visitor) => visitor.visitSend(this); 618 accept(Visitor visitor) => visitor.visitSend(this);
585 619
586 accept1(Visitor1 visitor, arg) => visitor.visitSend(this, arg); 620 accept1(Visitor1 visitor, arg) => visitor.visitSend(this, arg);
587 621
588 visitChildren(Visitor visitor) { 622 visitChildren(Visitor visitor) {
589 if (receiver != null) receiver.accept(visitor); 623 if (receiver != null) receiver.accept(visitor);
590 if (selector != null) selector.accept(visitor); 624 if (selector != null) selector.accept(visitor);
591 if (argumentsNode != null) argumentsNode.accept(visitor); 625 if (argumentsNode != null) argumentsNode.accept(visitor);
592 } 626 }
593 627
594 visitChildren1(Visitor1 visitor, arg) { 628 visitChildren1(Visitor1 visitor, arg) {
595 if (receiver != null) receiver.accept1(visitor, arg); 629 if (receiver != null) receiver.accept1(visitor, arg);
596 if (selector != null) selector.accept1(visitor, arg); 630 if (selector != null) selector.accept1(visitor, arg);
597 if (argumentsNode != null) argumentsNode.accept1(visitor, arg); 631 if (argumentsNode != null) argumentsNode.accept1(visitor, arg);
598 } 632 }
599 633
600 int argumentCount() { 634 int argumentCount() {
601 return (argumentsNode == null) ? -1 : argumentsNode.slowLength(); 635 return (argumentsNode == null) ? -1 : argumentsNode.slowLength();
602 } 636 }
603 637
604 bool get isSuperCall { 638 bool get isSuperCall {
605 return receiver != null && receiver.isSuper(); 639 return receiver != null && receiver.isSuper();
606 } 640 }
641
607 bool get isOperator => selector is Operator; 642 bool get isOperator => selector is Operator;
608 bool get isPropertyAccess => argumentsNode == null; 643 bool get isPropertyAccess => argumentsNode == null;
609 bool get isFunctionObjectInvocation => selector == null; 644 bool get isFunctionObjectInvocation => selector == null;
610 bool get isPrefix => argumentsNode is Prefix; 645 bool get isPrefix => argumentsNode is Prefix;
611 bool get isPostfix => argumentsNode is Postfix; 646 bool get isPostfix => argumentsNode is Postfix;
612 bool get isCall => !isOperator && !isPropertyAccess; 647 bool get isCall => !isOperator && !isPropertyAccess;
613 bool get isIndex => 648 bool get isIndex =>
614 isOperator && identical(selector.asOperator().source, '[]'); 649 isOperator && identical(selector.asOperator().source, '[]');
615 bool get isLogicalAnd => 650 bool get isLogicalAnd =>
616 isOperator && identical(selector.asOperator().source, '&&'); 651 isOperator && identical(selector.asOperator().source, '&&');
617 bool get isLogicalOr => 652 bool get isLogicalOr =>
618 isOperator && identical(selector.asOperator().source, '||'); 653 isOperator && identical(selector.asOperator().source, '||');
619 bool get isIfNull => 654 bool get isIfNull =>
620 isOperator && identical(selector.asOperator().source, '??'); 655 isOperator && identical(selector.asOperator().source, '??');
621 656
622 bool get isTypeCast { 657 bool get isTypeCast {
623 return isOperator 658 return isOperator && identical(selector.asOperator().source, 'as');
624 && identical(selector.asOperator().source, 'as');
625 } 659 }
626 660
627 bool get isTypeTest { 661 bool get isTypeTest {
628 return isOperator 662 return isOperator && identical(selector.asOperator().source, 'is');
629 && identical(selector.asOperator().source, 'is');
630 } 663 }
631 664
632 bool get isIsNotCheck { 665 bool get isIsNotCheck {
633 return isTypeTest && arguments.head.asSend() != null; 666 return isTypeTest && arguments.head.asSend() != null;
634 } 667 }
635 668
636 TypeAnnotation get typeAnnotationFromIsCheckOrCast { 669 TypeAnnotation get typeAnnotationFromIsCheckOrCast {
637 assert(isOperator); 670 assert(isOperator);
638 assert(identical(selector.asOperator().source, 'is') || 671 assert(identical(selector.asOperator().source, 'is') ||
639 identical(selector.asOperator().source, 'as')); 672 identical(selector.asOperator().source, 'as'));
640 return isIsNotCheck 673 return isIsNotCheck ? arguments.head.asSend().receiver : arguments.head;
641 ? arguments.head.asSend().receiver
642 : arguments.head;
643 } 674 }
644 675
645 Token getBeginToken() { 676 Token getBeginToken() {
646 if (isPrefix && !isIndex) return selector.getBeginToken(); 677 if (isPrefix && !isIndex) return selector.getBeginToken();
647 return firstBeginToken(receiver, selector); 678 return firstBeginToken(receiver, selector);
648 } 679 }
649 680
650 Token getEndToken() { 681 Token getEndToken() {
651 if (isPrefix) { 682 if (isPrefix) {
652 if (receiver != null) return receiver.getEndToken(); 683 if (receiver != null) return receiver.getEndToken();
(...skipping 21 matching lines...) Expand all
674 705
675 class Prefix extends NodeList { 706 class Prefix extends NodeList {
676 Prefix() : super(null, const Link<Node>()); 707 Prefix() : super(null, const Link<Node>());
677 Prefix.singleton(Node argument) : super.singleton(argument); 708 Prefix.singleton(Node argument) : super.singleton(argument);
678 } 709 }
679 710
680 class SendSet extends Send { 711 class SendSet extends Send {
681 final Operator assignmentOperator; 712 final Operator assignmentOperator;
682 SendSet(receiver, selector, this.assignmentOperator, argumentsNode, 713 SendSet(receiver, selector, this.assignmentOperator, argumentsNode,
683 [bool isConditional = false]) 714 [bool isConditional = false])
684 : super(receiver, selector, argumentsNode, isConditional); 715 : super(receiver, selector, argumentsNode, isConditional);
685 SendSet.postfix(receiver, 716 SendSet.postfix(receiver, selector, this.assignmentOperator,
686 selector, 717 [Node argument = null, bool isConditional = false])
687 this.assignmentOperator,
688 [Node argument = null, bool isConditional = false])
689 : super.postfix(receiver, selector, argument, isConditional); 718 : super.postfix(receiver, selector, argument, isConditional);
690 SendSet.prefix(receiver, 719 SendSet.prefix(receiver, selector, this.assignmentOperator,
691 selector, 720 [Node argument = null, bool isConditional = false])
692 this.assignmentOperator,
693 [Node argument = null, bool isConditional = false])
694 : super.prefix(receiver, selector, argument, isConditional); 721 : super.prefix(receiver, selector, argument, isConditional);
695 722
696 SendSet asSendSet() => this; 723 SendSet asSendSet() => this;
697 724
698 accept(Visitor visitor) => visitor.visitSendSet(this); 725 accept(Visitor visitor) => visitor.visitSendSet(this);
699 726
700 accept1(Visitor1 visitor, arg) => visitor.visitSendSet(this, arg); 727 accept1(Visitor1 visitor, arg) => visitor.visitSendSet(this, arg);
701 728
702 visitChildren(Visitor visitor) { 729 visitChildren(Visitor visitor) {
703 super.visitChildren(visitor); 730 super.visitChildren(visitor);
704 if (assignmentOperator != null) assignmentOperator.accept(visitor); 731 if (assignmentOperator != null) assignmentOperator.accept(visitor);
705 } 732 }
706 733
707 visitChildren1(Visitor1 visitor, arg) { 734 visitChildren1(Visitor1 visitor, arg) {
708 super.visitChildren1(visitor, arg); 735 super.visitChildren1(visitor, arg);
709 if (assignmentOperator != null) assignmentOperator.accept1(visitor, arg); 736 if (assignmentOperator != null) assignmentOperator.accept1(visitor, arg);
710 } 737 }
711 738
712 /// `true` if this send is not a simple assignment. 739 /// `true` if this send is not a simple assignment.
713 bool get isComplex => !identical(assignmentOperator.source, '='); 740 bool get isComplex => !identical(assignmentOperator.source, '=');
714 741
715 /// Whether this is an if-null assignment of the form `a ??= b`. 742 /// Whether this is an if-null assignment of the form `a ??= b`.
716 bool get isIfNullAssignment => 743 bool get isIfNullAssignment => identical(assignmentOperator.source, '??=');
717 identical(assignmentOperator.source, '??=');
718 744
719 Send copyWithReceiver(Node newReceiver, bool isConditional) { 745 Send copyWithReceiver(Node newReceiver, bool isConditional) {
720 assert(receiver == null); 746 assert(receiver == null);
721 return new SendSet(newReceiver, selector, assignmentOperator, 747 return new SendSet(newReceiver, selector, assignmentOperator, argumentsNode,
722 argumentsNode, isConditional); 748 isConditional);
723 } 749 }
724 750
725 Token getBeginToken() { 751 Token getBeginToken() {
726 if (isPrefix) return assignmentOperator.getBeginToken(); 752 if (isPrefix) return assignmentOperator.getBeginToken();
727 return super.getBeginToken(); 753 return super.getBeginToken();
728 } 754 }
729 755
730 Token getEndToken() { 756 Token getEndToken() {
731 if (isPostfix) return assignmentOperator.getEndToken(); 757 if (isPostfix) return assignmentOperator.getEndToken();
732 return super.getEndToken(); 758 return super.getEndToken();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 835
810 visitChildren1(Visitor1 visitor, arg) { 836 visitChildren1(Visitor1 visitor, arg) {
811 if (nodes == null) return; 837 if (nodes == null) return;
812 for (Link<Node> link = nodes; !link.isEmpty; link = link.tail) { 838 for (Link<Node> link = nodes; !link.isEmpty; link = link.tail) {
813 if (link.head != null) link.head.accept1(visitor, arg); 839 if (link.head != null) link.head.accept1(visitor, arg);
814 } 840 }
815 } 841 }
816 842
817 Token getBeginToken() { 843 Token getBeginToken() {
818 if (beginToken != null) return beginToken; 844 if (beginToken != null) return beginToken;
819 if (nodes != null) { 845 if (nodes != null) {
820 for (Link<Node> link = nodes; !link.isEmpty; link = link.tail) { 846 for (Link<Node> link = nodes; !link.isEmpty; link = link.tail) {
821 if (link.head.getBeginToken() != null) { 847 if (link.head.getBeginToken() != null) {
822 return link.head.getBeginToken(); 848 return link.head.getBeginToken();
823 } 849 }
824 if (link.head.getEndToken() != null) { 850 if (link.head.getEndToken() != null) {
825 return link.head.getEndToken(); 851 return link.head.getEndToken();
826 } 852 }
827 } 853 }
828 } 854 }
829 return endToken; 855 return endToken;
830 } 856 }
831 857
832 Token getEndToken() { 858 Token getEndToken() {
833 if (endToken != null) return endToken; 859 if (endToken != null) return endToken;
834 if (nodes != null) { 860 if (nodes != null) {
835 Link<Node> link = nodes; 861 Link<Node> link = nodes;
836 if (link.isEmpty) return beginToken; 862 if (link.isEmpty) return beginToken;
837 while (!link.tail.isEmpty) link = link.tail; 863 while (!link.tail.isEmpty) link = link.tail;
838 Node lastNode = link.head; 864 Node lastNode = link.head;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 } 896 }
871 897
872 class If extends Statement { 898 class If extends Statement {
873 final ParenthesizedExpression condition; 899 final ParenthesizedExpression condition;
874 final Statement thenPart; 900 final Statement thenPart;
875 final Statement elsePart; 901 final Statement elsePart;
876 902
877 final Token ifToken; 903 final Token ifToken;
878 final Token elseToken; 904 final Token elseToken;
879 905
880 If(this.condition, this.thenPart, this.elsePart, 906 If(this.condition, this.thenPart, this.elsePart, this.ifToken,
881 this.ifToken, this.elseToken); 907 this.elseToken);
882 908
883 If asIf() => this; 909 If asIf() => this;
884 910
885 bool get hasElsePart => elsePart != null; 911 bool get hasElsePart => elsePart != null;
886 912
887 accept(Visitor visitor) => visitor.visitIf(this); 913 accept(Visitor visitor) => visitor.visitIf(this);
888 914
889 accept1(Visitor1 visitor, arg) => visitor.visitIf(this, arg); 915 accept1(Visitor1 visitor, arg) => visitor.visitIf(this, arg);
890 916
891 visitChildren(Visitor visitor) { 917 visitChildren(Visitor visitor) {
(...skipping 17 matching lines...) Expand all
909 } 935 }
910 936
911 class Conditional extends Expression { 937 class Conditional extends Expression {
912 final Expression condition; 938 final Expression condition;
913 final Expression thenExpression; 939 final Expression thenExpression;
914 final Expression elseExpression; 940 final Expression elseExpression;
915 941
916 final Token questionToken; 942 final Token questionToken;
917 final Token colonToken; 943 final Token colonToken;
918 944
919 Conditional(this.condition, this.thenExpression, 945 Conditional(this.condition, this.thenExpression, this.elseExpression,
920 this.elseExpression, this.questionToken, this.colonToken); 946 this.questionToken, this.colonToken);
921 947
922 Conditional asConditional() => this; 948 Conditional asConditional() => this;
923 949
924 accept(Visitor visitor) => visitor.visitConditional(this); 950 accept(Visitor visitor) => visitor.visitConditional(this);
925 951
926 accept1(Visitor1 visitor, arg) => visitor.visitConditional(this, arg); 952 accept1(Visitor1 visitor, arg) => visitor.visitConditional(this, arg);
927 953
928 visitChildren(Visitor visitor) { 954 visitChildren(Visitor visitor) {
929 condition.accept(visitor); 955 condition.accept(visitor);
930 thenExpression.accept(visitor); 956 thenExpression.accept(visitor);
(...skipping 14 matching lines...) Expand all
945 class For extends Loop { 971 class For extends Loop {
946 /** Either a variable declaration or an expression. */ 972 /** Either a variable declaration or an expression. */
947 final Node initializer; 973 final Node initializer;
948 /** Either an expression statement or an empty statement. */ 974 /** Either an expression statement or an empty statement. */
949 final Statement conditionStatement; 975 final Statement conditionStatement;
950 final NodeList update; 976 final NodeList update;
951 977
952 final Token forToken; 978 final Token forToken;
953 979
954 For(this.initializer, this.conditionStatement, this.update, body, 980 For(this.initializer, this.conditionStatement, this.update, body,
955 this.forToken) : super(body); 981 this.forToken)
982 : super(body);
956 983
957 For asFor() => this; 984 For asFor() => this;
958 985
959 Expression get condition { 986 Expression get condition {
960 ExpressionStatement expressionStatement = 987 ExpressionStatement expressionStatement =
961 conditionStatement.asExpressionStatement(); 988 conditionStatement.asExpressionStatement();
962 if (expressionStatement != null) { 989 if (expressionStatement != null) {
963 return expressionStatement.expression; 990 return expressionStatement.expression;
964 } else { 991 } else {
965 return null; 992 return null;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 1085
1059 final Statement body; 1086 final Statement body;
1060 final TypeAnnotation returnType; 1087 final TypeAnnotation returnType;
1061 final Modifiers modifiers; 1088 final Modifiers modifiers;
1062 final NodeList initializers; 1089 final NodeList initializers;
1063 1090
1064 final Token getOrSet; 1091 final Token getOrSet;
1065 final AsyncModifier asyncModifier; 1092 final AsyncModifier asyncModifier;
1066 1093
1067 FunctionExpression(this.name, this.parameters, this.body, this.returnType, 1094 FunctionExpression(this.name, this.parameters, this.body, this.returnType,
1068 this.modifiers, this.initializers, this.getOrSet, 1095 this.modifiers, this.initializers, this.getOrSet, this.asyncModifier) {
1069 this.asyncModifier) {
1070 assert(modifiers != null); 1096 assert(modifiers != null);
1071 } 1097 }
1072 1098
1073 FunctionExpression asFunctionExpression() => this; 1099 FunctionExpression asFunctionExpression() => this;
1074 1100
1075 accept(Visitor visitor) => visitor.visitFunctionExpression(this); 1101 accept(Visitor visitor) => visitor.visitFunctionExpression(this);
1076 1102
1077 accept1(Visitor1 visitor, arg) => visitor.visitFunctionExpression(this, arg); 1103 accept1(Visitor1 visitor, arg) => visitor.visitFunctionExpression(this, arg);
1078 1104
1079 bool get isRedirectingFactory { 1105 bool get isRedirectingFactory {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 } 1189 }
1164 } 1190 }
1165 1191
1166 accept(Visitor visitor) => visitor.visitLiteralInt(this); 1192 accept(Visitor visitor) => visitor.visitLiteralInt(this);
1167 1193
1168 accept1(Visitor1 visitor, arg) => visitor.visitLiteralInt(this, arg); 1194 accept1(Visitor1 visitor, arg) => visitor.visitLiteralInt(this, arg);
1169 } 1195 }
1170 1196
1171 class LiteralDouble extends Literal<double> { 1197 class LiteralDouble extends Literal<double> {
1172 LiteralDouble(Token token, DecodeErrorHandler handler) 1198 LiteralDouble(Token token, DecodeErrorHandler handler)
1173 : super(token, handler); 1199 : super(token, handler);
1174 1200
1175 LiteralDouble asLiteralDouble() => this; 1201 LiteralDouble asLiteralDouble() => this;
1176 1202
1177 double get value { 1203 double get value {
1178 try { 1204 try {
1179 Token valueToken = token; 1205 Token valueToken = token;
1180 if (identical(valueToken.kind, Tokens.PLUS_TOKEN)) { 1206 if (identical(valueToken.kind, Tokens.PLUS_TOKEN)) {
1181 valueToken = valueToken.next; 1207 valueToken = valueToken.next;
1182 } 1208 }
1183 return double.parse(valueToken.value); 1209 return double.parse(valueToken.value);
(...skipping 17 matching lines...) Expand all
1201 if (identical(token.stringValue, 'false')) return false; 1227 if (identical(token.stringValue, 'false')) return false;
1202 (this.handler)(token, "not a bool ${token.value}"); 1228 (this.handler)(token, "not a bool ${token.value}");
1203 throw false; 1229 throw false;
1204 } 1230 }
1205 1231
1206 accept(Visitor visitor) => visitor.visitLiteralBool(this); 1232 accept(Visitor visitor) => visitor.visitLiteralBool(this);
1207 1233
1208 accept1(Visitor1 visitor, arg) => visitor.visitLiteralBool(this, arg); 1234 accept1(Visitor1 visitor, arg) => visitor.visitLiteralBool(this, arg);
1209 } 1235 }
1210 1236
1211
1212 class StringQuoting { 1237 class StringQuoting {
1213
1214 /// Cache of common quotings. 1238 /// Cache of common quotings.
1215 static const List<StringQuoting> _mapping = const <StringQuoting>[ 1239 static const List<StringQuoting> _mapping = const <StringQuoting>[
1216 const StringQuoting($SQ, raw: false, leftQuoteLength: 1), 1240 const StringQuoting($SQ, raw: false, leftQuoteLength: 1),
1217 const StringQuoting($SQ, raw: true, leftQuoteLength: 1), 1241 const StringQuoting($SQ, raw: true, leftQuoteLength: 1),
1218 const StringQuoting($DQ, raw: false, leftQuoteLength: 1), 1242 const StringQuoting($DQ, raw: false, leftQuoteLength: 1),
1219 const StringQuoting($DQ, raw: true, leftQuoteLength: 1), 1243 const StringQuoting($DQ, raw: true, leftQuoteLength: 1),
1220 // No string quotes with 2 characters. 1244 // No string quotes with 2 characters.
1221 null, 1245 null,
1222 null, 1246 null,
1223 null, 1247 null,
(...skipping 15 matching lines...) Expand all
1239 const StringQuoting($DQ, raw: true, leftQuoteLength: 5), 1263 const StringQuoting($DQ, raw: true, leftQuoteLength: 5),
1240 const StringQuoting($SQ, raw: false, leftQuoteLength: 6), 1264 const StringQuoting($SQ, raw: false, leftQuoteLength: 6),
1241 const StringQuoting($SQ, raw: true, leftQuoteLength: 6), 1265 const StringQuoting($SQ, raw: true, leftQuoteLength: 6),
1242 const StringQuoting($DQ, raw: false, leftQuoteLength: 6), 1266 const StringQuoting($DQ, raw: false, leftQuoteLength: 6),
1243 const StringQuoting($DQ, raw: true, leftQuoteLength: 6) 1267 const StringQuoting($DQ, raw: true, leftQuoteLength: 6)
1244 ]; 1268 ];
1245 1269
1246 final bool raw; 1270 final bool raw;
1247 final int leftQuoteCharCount; 1271 final int leftQuoteCharCount;
1248 final int quote; 1272 final int quote;
1249 const StringQuoting(this.quote, { this.raw, int leftQuoteLength }) 1273 const StringQuoting(this.quote, {this.raw, int leftQuoteLength})
1250 : this.leftQuoteCharCount = leftQuoteLength; 1274 : this.leftQuoteCharCount = leftQuoteLength;
1251 String get quoteChar => identical(quote, $DQ) ? '"' : "'"; 1275 String get quoteChar => identical(quote, $DQ) ? '"' : "'";
1252 1276
1253 int get leftQuoteLength => (raw ? 1 : 0) + leftQuoteCharCount; 1277 int get leftQuoteLength => (raw ? 1 : 0) + leftQuoteCharCount;
1254 int get rightQuoteLength => (leftQuoteCharCount > 2) ? 3 : 1; 1278 int get rightQuoteLength => (leftQuoteCharCount > 2) ? 3 : 1;
1255 static StringQuoting getQuoting(int quote, bool raw, int leftQuoteLength) { 1279 static StringQuoting getQuoting(int quote, bool raw, int leftQuoteLength) {
1256 int quoteKindOffset = (quote == $DQ) ? 2 : 0; 1280 int quoteKindOffset = (quote == $DQ) ? 2 : 0;
1257 int rawOffset = raw ? 1 : 0; 1281 int rawOffset = raw ? 1 : 0;
1258 int index = (leftQuoteLength - 1) * 4 + rawOffset + quoteKindOffset; 1282 int index = (leftQuoteLength - 1) * 4 + rawOffset + quoteKindOffset;
1259 if (index < _mapping.length) return _mapping[index]; 1283 if (index < _mapping.length) return _mapping[index];
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 Token getEndToken() => identifiers.getEndToken(); 1447 Token getEndToken() => identifiers.getEndToken();
1424 1448
1425 String get slowNameString { 1449 String get slowNameString {
1426 Unparser unparser = new Unparser(); 1450 Unparser unparser = new Unparser();
1427 unparser.unparseNodeListOfIdentifiers(identifiers); 1451 unparser.unparseNodeListOfIdentifiers(identifiers);
1428 return unparser.result; 1452 return unparser.result;
1429 } 1453 }
1430 } 1454 }
1431 1455
1432 class Operator extends Identifier { 1456 class Operator extends Identifier {
1433 static const COMPLEX_OPERATORS = 1457 static const COMPLEX_OPERATORS = const [
1434 const ["--", "++", '+=', "-=", "*=", "/=", "%=", "&=", "|=", "~/=", "^=", 1458 "--",
1435 ">>=", "<<=", "??="]; 1459 "++",
1460 '+=',
1461 "-=",
1462 "*=",
1463 "/=",
1464 "%=",
1465 "&=",
1466 "|=",
1467 "~/=",
1468 "^=",
1469 ">>=",
1470 "<<=",
1471 "??="
1472 ];
1436 1473
1437 static const INCREMENT_OPERATORS = const <String>["++", "--"]; 1474 static const INCREMENT_OPERATORS = const <String>["++", "--"];
1438 1475
1439 Operator(Token token) : super(token); 1476 Operator(Token token) : super(token);
1440 1477
1441 Operator asOperator() => this; 1478 Operator asOperator() => this;
1442 1479
1443 accept(Visitor visitor) => visitor.visitOperator(this); 1480 accept(Visitor visitor) => visitor.visitOperator(this);
1444 1481
1445 accept1(Visitor1 visitor, arg) => visitor.visitOperator(this, arg); 1482 accept1(Visitor1 visitor, arg) => visitor.visitOperator(this, arg);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 Token getBeginToken() => yieldToken; 1543 Token getBeginToken() => yieldToken;
1507 1544
1508 Token getEndToken() => endToken; 1545 Token getEndToken() => endToken;
1509 } 1546 }
1510 1547
1511 class RedirectingFactoryBody extends Statement with StoredTreeElementMixin { 1548 class RedirectingFactoryBody extends Statement with StoredTreeElementMixin {
1512 final Node constructorReference; 1549 final Node constructorReference;
1513 final Token beginToken; 1550 final Token beginToken;
1514 final Token endToken; 1551 final Token endToken;
1515 1552
1516 RedirectingFactoryBody(this.beginToken, this.endToken, 1553 RedirectingFactoryBody(
1517 this.constructorReference); 1554 this.beginToken, this.endToken, this.constructorReference);
1518 1555
1519 RedirectingFactoryBody asRedirectingFactoryBody() => this; 1556 RedirectingFactoryBody asRedirectingFactoryBody() => this;
1520 1557
1521 accept(Visitor visitor) => visitor.visitRedirectingFactoryBody(this); 1558 accept(Visitor visitor) => visitor.visitRedirectingFactoryBody(this);
1522 1559
1523 accept1(Visitor1 visitor, arg) { 1560 accept1(Visitor1 visitor, arg) {
1524 return visitor.visitRedirectingFactoryBody(this, arg); 1561 return visitor.visitRedirectingFactoryBody(this, arg);
1525 } 1562 }
1526 1563
1527 visitChildren(Visitor visitor) { 1564 visitChildren(Visitor visitor) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 final Token endToken; 1688 final Token endToken;
1652 1689
1653 Rethrow(this.throwToken, this.endToken); 1690 Rethrow(this.throwToken, this.endToken);
1654 1691
1655 Rethrow asRethrow() => this; 1692 Rethrow asRethrow() => this;
1656 1693
1657 accept(Visitor visitor) => visitor.visitRethrow(this); 1694 accept(Visitor visitor) => visitor.visitRethrow(this);
1658 1695
1659 accept1(Visitor1 visitor, arg) => visitor.visitRethrow(this, arg); 1696 accept1(Visitor1 visitor, arg) => visitor.visitRethrow(this, arg);
1660 1697
1661 visitChildren(Visitor visitor) { } 1698 visitChildren(Visitor visitor) {}
1662 1699
1663 visitChildren1(Visitor1 visitor, arg) { } 1700 visitChildren1(Visitor1 visitor, arg) {}
1664 1701
1665 Token getBeginToken() => throwToken; 1702 Token getBeginToken() => throwToken;
1666 Token getEndToken() => endToken; 1703 Token getEndToken() => endToken;
1667 } 1704 }
1668 1705
1669 class TypeAnnotation extends Node { 1706 class TypeAnnotation extends Node {
1670 final Expression typeName; 1707 final Expression typeName;
1671 final NodeList typeArguments; 1708 final NodeList typeArguments;
1672 1709
1673 TypeAnnotation(Expression this.typeName, NodeList this.typeArguments); 1710 TypeAnnotation(Expression this.typeName, NodeList this.typeArguments);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 return (bound != null) ? bound.getEndToken() : name.getEndToken(); 1764 return (bound != null) ? bound.getEndToken() : name.getEndToken();
1728 } 1765 }
1729 } 1766 }
1730 1767
1731 class VariableDefinitions extends Statement { 1768 class VariableDefinitions extends Statement {
1732 final NodeList metadata; 1769 final NodeList metadata;
1733 final TypeAnnotation type; 1770 final TypeAnnotation type;
1734 final Modifiers modifiers; 1771 final Modifiers modifiers;
1735 final NodeList definitions; 1772 final NodeList definitions;
1736 1773
1737 VariableDefinitions(this.type, 1774 VariableDefinitions(this.type, this.modifiers, this.definitions)
1738 this.modifiers,
1739 this.definitions)
1740 : this.metadata = null { 1775 : this.metadata = null {
1741 assert(modifiers != null); 1776 assert(modifiers != null);
1742 } 1777 }
1743 1778
1744 // TODO(johnniwinther): Make this its own node type. 1779 // TODO(johnniwinther): Make this its own node type.
1745 VariableDefinitions.forParameter(this.metadata, 1780 VariableDefinitions.forParameter(
1746 this.type, 1781 this.metadata, this.type, this.modifiers, this.definitions) {
1747 this.modifiers,
1748 this.definitions) {
1749 assert(modifiers != null); 1782 assert(modifiers != null);
1750 } 1783 }
1751 1784
1752 VariableDefinitions asVariableDefinitions() => this; 1785 VariableDefinitions asVariableDefinitions() => this;
1753 1786
1754 accept(Visitor visitor) => visitor.visitVariableDefinitions(this); 1787 accept(Visitor visitor) => visitor.visitVariableDefinitions(this);
1755 1788
1756 accept1(Visitor1 visitor, arg) => visitor.visitVariableDefinitions(this, arg); 1789 accept1(Visitor1 visitor, arg) => visitor.visitVariableDefinitions(this, arg);
1757 1790
1758 visitChildren(Visitor visitor) { 1791 visitChildren(Visitor visitor) {
(...skipping 28 matching lines...) Expand all
1787 bool isValidContinueTarget() => true; 1820 bool isValidContinueTarget() => true;
1788 } 1821 }
1789 1822
1790 class DoWhile extends Loop { 1823 class DoWhile extends Loop {
1791 final Token doKeyword; 1824 final Token doKeyword;
1792 final Token whileKeyword; 1825 final Token whileKeyword;
1793 final Token endToken; 1826 final Token endToken;
1794 1827
1795 final Expression condition; 1828 final Expression condition;
1796 1829
1797 DoWhile(Statement body, Expression this.condition, 1830 DoWhile(Statement body, Expression this.condition, Token this.doKeyword,
1798 Token this.doKeyword, Token this.whileKeyword, Token this.endToken) 1831 Token this.whileKeyword, Token this.endToken)
1799 : super(body); 1832 : super(body);
1800 1833
1801 DoWhile asDoWhile() => this; 1834 DoWhile asDoWhile() => this;
1802 1835
1803 accept(Visitor visitor) => visitor.visitDoWhile(this); 1836 accept(Visitor visitor) => visitor.visitDoWhile(this);
1804 1837
1805 accept1(Visitor1 visitor, arg) => visitor.visitDoWhile(this, arg); 1838 accept1(Visitor1 visitor, arg) => visitor.visitDoWhile(this, arg);
1806 1839
1807 visitChildren(Visitor visitor) { 1840 visitChildren(Visitor visitor) {
1808 if (condition != null) condition.accept(visitor); 1841 if (condition != null) condition.accept(visitor);
1809 if (body != null) body.accept(visitor); 1842 if (body != null) body.accept(visitor);
1810 } 1843 }
1811 1844
1812 visitChildren1(Visitor1 visitor, arg) { 1845 visitChildren1(Visitor1 visitor, arg) {
1813 if (condition != null) condition.accept1(visitor, arg); 1846 if (condition != null) condition.accept1(visitor, arg);
1814 if (body != null) body.accept1(visitor, arg); 1847 if (body != null) body.accept1(visitor, arg);
1815 } 1848 }
1816 1849
1817 Token getBeginToken() => doKeyword; 1850 Token getBeginToken() => doKeyword;
1818 1851
1819 Token getEndToken() => endToken; 1852 Token getEndToken() => endToken;
1820 } 1853 }
1821 1854
1822 class While extends Loop { 1855 class While extends Loop {
1823 final Token whileKeyword; 1856 final Token whileKeyword;
1824 final Expression condition; 1857 final Expression condition;
1825 1858
1826 While(Expression this.condition, Statement body, 1859 While(Expression this.condition, Statement body, Token this.whileKeyword)
1827 Token this.whileKeyword) : super(body); 1860 : super(body);
1828 1861
1829 While asWhile() => this; 1862 While asWhile() => this;
1830 1863
1831 accept(Visitor visitor) => visitor.visitWhile(this); 1864 accept(Visitor visitor) => visitor.visitWhile(this);
1832 1865
1833 accept1(Visitor1 visitor, arg) => visitor.visitWhile(this, arg); 1866 accept1(Visitor1 visitor, arg) => visitor.visitWhile(this, arg);
1834 1867
1835 visitChildren(Visitor visitor) { 1868 visitChildren(Visitor visitor) {
1836 if (condition != null) condition.accept(visitor); 1869 if (condition != null) condition.accept(visitor);
1837 if (body != null) body.accept(visitor); 1870 if (body != null) body.accept(visitor);
1838 } 1871 }
1839 1872
1840 visitChildren1(Visitor1 visitor, arg) { 1873 visitChildren1(Visitor1 visitor, arg) {
1841 if (condition != null) condition.accept1(visitor, arg); 1874 if (condition != null) condition.accept1(visitor, arg);
1842 if (body != null) body.accept1(visitor, arg); 1875 if (body != null) body.accept1(visitor, arg);
1843 } 1876 }
1844 1877
1845 Token getBeginToken() => whileKeyword; 1878 Token getBeginToken() => whileKeyword;
1846 1879
1847 Token getEndToken() => body.getEndToken(); 1880 Token getEndToken() => body.getEndToken();
1848 } 1881 }
1849 1882
1850 class ParenthesizedExpression extends Expression { 1883 class ParenthesizedExpression extends Expression {
1851 final Expression expression; 1884 final Expression expression;
1852 final BeginGroupToken beginToken; 1885 final BeginGroupToken beginToken;
1853 1886
1854 ParenthesizedExpression(Expression this.expression, 1887 ParenthesizedExpression(
1855 BeginGroupToken this.beginToken); 1888 Expression this.expression, BeginGroupToken this.beginToken);
1856 1889
1857 ParenthesizedExpression asParenthesizedExpression() => this; 1890 ParenthesizedExpression asParenthesizedExpression() => this;
1858 1891
1859 accept(Visitor visitor) => visitor.visitParenthesizedExpression(this); 1892 accept(Visitor visitor) => visitor.visitParenthesizedExpression(this);
1860 1893
1861 accept1(Visitor1 visitor, arg) { 1894 accept1(Visitor1 visitor, arg) {
1862 return visitor.visitParenthesizedExpression(this, arg); 1895 return visitor.visitParenthesizedExpression(this, arg);
1863 } 1896 }
1864 1897
1865 visitChildren(Visitor visitor) { 1898 visitChildren(Visitor visitor) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 static const int FLAG_EXTERNAL = FLAG_FACTORY << 1; 1935 static const int FLAG_EXTERNAL = FLAG_FACTORY << 1;
1903 1936
1904 Modifiers(NodeList nodes) : this.withFlags(nodes, computeFlags(nodes.nodes)); 1937 Modifiers(NodeList nodes) : this.withFlags(nodes, computeFlags(nodes.nodes));
1905 1938
1906 Modifiers.withFlags(this.nodes, this.flags); 1939 Modifiers.withFlags(this.nodes, this.flags);
1907 1940
1908 static int computeFlags(Link<Node> nodes) { 1941 static int computeFlags(Link<Node> nodes) {
1909 int flags = 0; 1942 int flags = 0;
1910 for (; !nodes.isEmpty; nodes = nodes.tail) { 1943 for (; !nodes.isEmpty; nodes = nodes.tail) {
1911 String value = nodes.head.asIdentifier().source; 1944 String value = nodes.head.asIdentifier().source;
1912 if (identical(value, 'static')) flags |= FLAG_STATIC; 1945 if (identical(value, 'static'))
1913 else if (identical(value, 'abstract')) flags |= FLAG_ABSTRACT; 1946 flags |= FLAG_STATIC;
1914 else if (identical(value, 'final')) flags |= FLAG_FINAL; 1947 else if (identical(value, 'abstract'))
1915 else if (identical(value, 'var')) flags |= FLAG_VAR; 1948 flags |= FLAG_ABSTRACT;
1916 else if (identical(value, 'const')) flags |= FLAG_CONST; 1949 else if (identical(value, 'final'))
1917 else if (identical(value, 'factory')) flags |= FLAG_FACTORY; 1950 flags |= FLAG_FINAL;
1918 else if (identical(value, 'external')) flags |= FLAG_EXTERNAL; 1951 else if (identical(value, 'var'))
1919 else throw 'internal error: ${nodes.head}'; 1952 flags |= FLAG_VAR;
1953 else if (identical(value, 'const'))
1954 flags |= FLAG_CONST;
1955 else if (identical(value, 'factory'))
1956 flags |= FLAG_FACTORY;
1957 else if (identical(value, 'external'))
1958 flags |= FLAG_EXTERNAL;
1959 else
1960 throw 'internal error: ${nodes.head}';
1920 } 1961 }
1921 return flags; 1962 return flags;
1922 } 1963 }
1923 1964
1924 Node findModifier(String modifier) { 1965 Node findModifier(String modifier) {
1925 Link<Node> nodeList = nodes.nodes; 1966 Link<Node> nodeList = nodes.nodes;
1926 for (; !nodeList.isEmpty; nodeList = nodeList.tail) { 1967 for (; !nodeList.isEmpty; nodeList = nodeList.tail) {
1927 String value = nodeList.head.asIdentifier().source; 1968 String value = nodeList.head.asIdentifier().source;
1928 if(identical(value, modifier)) { 1969 if (identical(value, modifier)) {
1929 return nodeList.head; 1970 return nodeList.head;
1930 } 1971 }
1931 } 1972 }
1932 return null; 1973 return null;
1933 } 1974 }
1934 1975
1935 Modifiers asModifiers() => this; 1976 Modifiers asModifiers() => this;
1936 Token getBeginToken() => nodes.getBeginToken(); 1977 Token getBeginToken() => nodes.getBeginToken();
1937 Token getEndToken() => nodes.getEndToken(); 1978 Token getEndToken() => nodes.getEndToken();
1938 1979
(...skipping 15 matching lines...) Expand all
1954 1995
1955 Node getStatic() => findModifier('static'); 1996 Node getStatic() => findModifier('static');
1956 1997
1957 /** 1998 /**
1958 * Use this to check if the declaration is either explicitly or implicitly 1999 * Use this to check if the declaration is either explicitly or implicitly
1959 * final. 2000 * final.
1960 */ 2001 */
1961 bool get isFinalOrConst => isFinal || isConst; 2002 bool get isFinalOrConst => isFinal || isConst;
1962 2003
1963 String toString() { 2004 String toString() {
1964 return modifiersToString(isStatic: isStatic, 2005 return modifiersToString(
1965 isAbstract: isAbstract, 2006 isStatic: isStatic,
1966 isFinal: isFinal, 2007 isAbstract: isAbstract,
1967 isVar: isVar, 2008 isFinal: isFinal,
1968 isConst: isConst, 2009 isVar: isVar,
1969 isFactory: isFactory, 2010 isConst: isConst,
1970 isExternal: isExternal); 2011 isFactory: isFactory,
2012 isExternal: isExternal);
1971 } 2013 }
1972 } 2014 }
1973 2015
1974 class StringInterpolation extends StringNode { 2016 class StringInterpolation extends StringNode {
1975 final LiteralString string; 2017 final LiteralString string;
1976 final NodeList parts; 2018 final NodeList parts;
1977 2019
1978 StringInterpolation(this.string, this.parts); 2020 StringInterpolation(this.string, this.parts);
1979 2021
1980 StringInterpolation asStringInterpolation() => this; 2022 StringInterpolation asStringInterpolation() => this;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 */ 2092 */
2051 DartString dartStringCache = null; 2093 DartString dartStringCache = null;
2052 2094
2053 StringJuxtaposition(this.first, this.second); 2095 StringJuxtaposition(this.first, this.second);
2054 2096
2055 StringJuxtaposition asStringJuxtaposition() => this; 2097 StringJuxtaposition asStringJuxtaposition() => this;
2056 2098
2057 bool get isInterpolation { 2099 bool get isInterpolation {
2058 if (isInterpolationCache == null) { 2100 if (isInterpolationCache == null) {
2059 isInterpolationCache = (first.accept(const IsInterpolationVisitor()) || 2101 isInterpolationCache = (first.accept(const IsInterpolationVisitor()) ||
2060 second.accept(const IsInterpolationVisitor())); 2102 second.accept(const IsInterpolationVisitor()));
2061 } 2103 }
2062 return isInterpolationCache; 2104 return isInterpolationCache;
2063 } 2105 }
2064 2106
2065 /** 2107 /**
2066 * Retrieve a single DartString that represents this entire juxtaposition 2108 * Retrieve a single DartString that represents this entire juxtaposition
2067 * of string literals. 2109 * of string literals.
2068 * Should only be called if [isInterpolation] returns false. 2110 * Should only be called if [isInterpolation] returns false.
2069 */ 2111 */
2070 DartString get dartString { 2112 DartString get dartString {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 2255
2214 Token getEndToken() => expression.getEndToken(); 2256 Token getEndToken() => expression.getEndToken();
2215 } 2257 }
2216 2258
2217 class SwitchStatement extends Statement { 2259 class SwitchStatement extends Statement {
2218 final ParenthesizedExpression parenthesizedExpression; 2260 final ParenthesizedExpression parenthesizedExpression;
2219 final NodeList cases; 2261 final NodeList cases;
2220 2262
2221 final Token switchKeyword; 2263 final Token switchKeyword;
2222 2264
2223 SwitchStatement(this.parenthesizedExpression, this.cases, 2265 SwitchStatement(this.parenthesizedExpression, this.cases, this.switchKeyword);
2224 this.switchKeyword);
2225 2266
2226 SwitchStatement asSwitchStatement() => this; 2267 SwitchStatement asSwitchStatement() => this;
2227 2268
2228 Expression get expression => parenthesizedExpression.expression; 2269 Expression get expression => parenthesizedExpression.expression;
2229 2270
2230 accept(Visitor visitor) => visitor.visitSwitchStatement(this); 2271 accept(Visitor visitor) => visitor.visitSwitchStatement(this);
2231 2272
2232 accept1(Visitor1 visitor, arg) => visitor.visitSwitchStatement(this, arg); 2273 accept1(Visitor1 visitor, arg) => visitor.visitSwitchStatement(this, arg);
2233 2274
2234 visitChildren(Visitor visitor) { 2275 visitChildren(Visitor visitor) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 2317
2277 /** List of [Label] and [CaseMatch] nodes. */ 2318 /** List of [Label] and [CaseMatch] nodes. */
2278 final NodeList labelsAndCases; 2319 final NodeList labelsAndCases;
2279 /** A "default" keyword token, if applicable. */ 2320 /** A "default" keyword token, if applicable. */
2280 final Token defaultKeyword; 2321 final Token defaultKeyword;
2281 /** List of statements, the body of the case. */ 2322 /** List of statements, the body of the case. */
2282 final NodeList statements; 2323 final NodeList statements;
2283 2324
2284 final Token startToken; 2325 final Token startToken;
2285 2326
2286 SwitchCase(this.labelsAndCases, this.defaultKeyword, 2327 SwitchCase(this.labelsAndCases, this.defaultKeyword, this.statements,
2287 this.statements, this.startToken); 2328 this.startToken);
2288 2329
2289 SwitchCase asSwitchCase() => this; 2330 SwitchCase asSwitchCase() => this;
2290 2331
2291 bool get isDefaultCase => defaultKeyword != null; 2332 bool get isDefaultCase => defaultKeyword != null;
2292 2333
2293 bool isValidContinueTarget() => true; 2334 bool isValidContinueTarget() => true;
2294 2335
2295 accept(Visitor visitor) => visitor.visitSwitchCase(this); 2336 accept(Visitor visitor) => visitor.visitSwitchCase(this);
2296 2337
2297 accept1(Visitor1 visitor, arg) => visitor.visitSwitchCase(this, arg); 2338 accept1(Visitor1 visitor, arg) => visitor.visitSwitchCase(this, arg);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 Token getBeginToken() => keywordToken; 2384 Token getBeginToken() => keywordToken;
2344 2385
2345 Token getEndToken() => semicolonToken; 2386 Token getEndToken() => semicolonToken;
2346 2387
2347 // TODO(ahe): make class abstract instead of adding an abstract method. 2388 // TODO(ahe): make class abstract instead of adding an abstract method.
2348 accept(Visitor visitor); 2389 accept(Visitor visitor);
2349 } 2390 }
2350 2391
2351 class BreakStatement extends GotoStatement { 2392 class BreakStatement extends GotoStatement {
2352 BreakStatement(Identifier target, Token keywordToken, Token semicolonToken) 2393 BreakStatement(Identifier target, Token keywordToken, Token semicolonToken)
2353 : super(target, keywordToken, semicolonToken); 2394 : super(target, keywordToken, semicolonToken);
2354 2395
2355 BreakStatement asBreakStatement() => this; 2396 BreakStatement asBreakStatement() => this;
2356 2397
2357 accept(Visitor visitor) => visitor.visitBreakStatement(this); 2398 accept(Visitor visitor) => visitor.visitBreakStatement(this);
2358 2399
2359 accept1(Visitor1 visitor, arg) => visitor.visitBreakStatement(this, arg); 2400 accept1(Visitor1 visitor, arg) => visitor.visitBreakStatement(this, arg);
2360 } 2401 }
2361 2402
2362 class ContinueStatement extends GotoStatement { 2403 class ContinueStatement extends GotoStatement {
2363 ContinueStatement(Identifier target, Token keywordToken, Token semicolonToken) 2404 ContinueStatement(Identifier target, Token keywordToken, Token semicolonToken)
2364 : super(target, keywordToken, semicolonToken); 2405 : super(target, keywordToken, semicolonToken);
2365 2406
2366 ContinueStatement asContinueStatement() => this; 2407 ContinueStatement asContinueStatement() => this;
2367 2408
2368 accept(Visitor visitor) => visitor.visitContinueStatement(this); 2409 accept(Visitor visitor) => visitor.visitContinueStatement(this);
2369 2410
2370 accept1(Visitor1 visitor, arg) => visitor.visitContinueStatement(this, arg); 2411 accept1(Visitor1 visitor, arg) => visitor.visitContinueStatement(this, arg);
2371 } 2412 }
2372 2413
2373 abstract class ForIn extends Loop { 2414 abstract class ForIn extends Loop {
2374 final Node declaredIdentifier; 2415 final Node declaredIdentifier;
2375 final Expression expression; 2416 final Expression expression;
2376 2417
2377 final Token forToken; 2418 final Token forToken;
2378 final Token inToken; 2419 final Token inToken;
2379 2420
2380 ForIn(this.declaredIdentifier, this.expression, 2421 ForIn(this.declaredIdentifier, this.expression, Statement body, this.forToken,
2381 Statement body, this.forToken, this.inToken) 2422 this.inToken)
2382 : super(body); 2423 : super(body);
2383 2424
2384 Expression get condition => null; 2425 Expression get condition => null;
2385 2426
2386 ForIn asForIn() => this; 2427 ForIn asForIn() => this;
2387 2428
2388 Token getEndToken() => body.getEndToken(); 2429 Token getEndToken() => body.getEndToken();
2389 } 2430 }
2390 2431
2391 class SyncForIn extends ForIn with StoredTreeElementMixin { 2432 class SyncForIn extends ForIn with StoredTreeElementMixin {
(...skipping 17 matching lines...) Expand all
2409 expression.accept1(visitor, arg); 2450 expression.accept1(visitor, arg);
2410 body.accept1(visitor, arg); 2451 body.accept1(visitor, arg);
2411 } 2452 }
2412 2453
2413 Token getBeginToken() => forToken; 2454 Token getBeginToken() => forToken;
2414 } 2455 }
2415 2456
2416 class AsyncForIn extends ForIn with StoredTreeElementMixin { 2457 class AsyncForIn extends ForIn with StoredTreeElementMixin {
2417 final Token awaitToken; 2458 final Token awaitToken;
2418 2459
2419 AsyncForIn(declaredIdentifier, expression, 2460 AsyncForIn(declaredIdentifier, expression, Statement body, this.awaitToken,
2420 Statement body, this.awaitToken, forToken, inToken) 2461 forToken, inToken)
2421 : super(declaredIdentifier, expression, body, forToken, inToken); 2462 : super(declaredIdentifier, expression, body, forToken, inToken);
2422 2463
2423 AsyncForIn asAsyncForIn() => this; 2464 AsyncForIn asAsyncForIn() => this;
2424 2465
2425 accept(Visitor visitor) => visitor.visitAsyncForIn(this); 2466 accept(Visitor visitor) => visitor.visitAsyncForIn(this);
2426 2467
2427 accept1(Visitor1 visitor, arg) => visitor.visitAsyncForIn(this, arg); 2468 accept1(Visitor1 visitor, arg) => visitor.visitAsyncForIn(this, arg);
2428 2469
2429 visitChildren(Visitor visitor) { 2470 visitChildren(Visitor visitor) {
2430 declaredIdentifier.accept(visitor); 2471 declaredIdentifier.accept(visitor);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2506 bool get isExport => false; 2547 bool get isExport => false;
2507 bool get isPart => false; 2548 bool get isPart => false;
2508 bool get isPartOf => false; 2549 bool get isPartOf => false;
2509 } 2550 }
2510 2551
2511 class LibraryName extends LibraryTag { 2552 class LibraryName extends LibraryTag {
2512 final Expression name; 2553 final Expression name;
2513 2554
2514 final Token libraryKeyword; 2555 final Token libraryKeyword;
2515 2556
2516 LibraryName(this.libraryKeyword, 2557 LibraryName(this.libraryKeyword, this.name, List<MetadataAnnotation> metadata)
2517 this.name, 2558 : super(metadata);
2518 List<MetadataAnnotation> metadata)
2519 : super(metadata);
2520 2559
2521 bool get isLibraryName => true; 2560 bool get isLibraryName => true;
2522 2561
2523 LibraryName asLibraryName() => this; 2562 LibraryName asLibraryName() => this;
2524 2563
2525 accept(Visitor visitor) => visitor.visitLibraryName(this); 2564 accept(Visitor visitor) => visitor.visitLibraryName(this);
2526 2565
2527 accept1(Visitor1 visitor, arg) => visitor.visitLibraryName(this, arg); 2566 accept1(Visitor1 visitor, arg) => visitor.visitLibraryName(this, arg);
2528 2567
2529 visitChildren(Visitor visitor) => name.accept(visitor); 2568 visitChildren(Visitor visitor) => name.accept(visitor);
2530 2569
2531 visitChildren1(Visitor1 visitor, arg) => name.accept1(visitor, arg); 2570 visitChildren1(Visitor1 visitor, arg) => name.accept1(visitor, arg);
2532 2571
2533 Token getBeginToken() => libraryKeyword; 2572 Token getBeginToken() => libraryKeyword;
2534 2573
2535 Token getEndToken() => name.getEndToken().next; 2574 Token getEndToken() => name.getEndToken().next;
2536 } 2575 }
2537 2576
2538 /** 2577 /**
2539 * This tag describes a dependency between one library and the exported 2578 * This tag describes a dependency between one library and the exported
2540 * identifiers of another library. The other library is specified by the [uri]. 2579 * identifiers of another library. The other library is specified by the [uri].
2541 * Combinators filter away some identifiers from the other library. 2580 * Combinators filter away some identifiers from the other library.
2542 */ 2581 */
2543 abstract class LibraryDependency extends LibraryTag { 2582 abstract class LibraryDependency extends LibraryTag {
2544 final StringNode uri; 2583 final StringNode uri;
2545 final NodeList conditionalUris; 2584 final NodeList conditionalUris;
2546 final NodeList combinators; 2585 final NodeList combinators;
2547 2586
2548 LibraryDependency(this.uri, 2587 LibraryDependency(this.uri, this.conditionalUris, this.combinators,
2549 this.conditionalUris, 2588 List<MetadataAnnotation> metadata)
2550 this.combinators, 2589 : super(metadata);
2551 List<MetadataAnnotation> metadata)
2552 : super(metadata);
2553 2590
2554 LibraryDependency asLibraryDependency() => this; 2591 LibraryDependency asLibraryDependency() => this;
2555 2592
2556 bool get hasConditionalUris => conditionalUris != null; 2593 bool get hasConditionalUris => conditionalUris != null;
2557 } 2594 }
2558 2595
2559 /** 2596 /**
2560 * An [:import:] library tag. 2597 * An [:import:] library tag.
2561 * 2598 *
2562 * An import tag is dependency on another library where the exported identifiers 2599 * An import tag is dependency on another library where the exported identifiers
2563 * are put into the import scope of the importing library. The import scope is 2600 * are put into the import scope of the importing library. The import scope is
2564 * only visible inside the library. 2601 * only visible inside the library.
2565 */ 2602 */
2566 class Import extends LibraryDependency { 2603 class Import extends LibraryDependency {
2567 final Identifier prefix; 2604 final Identifier prefix;
2568 final Token importKeyword; 2605 final Token importKeyword;
2569 final bool isDeferred; 2606 final bool isDeferred;
2570 2607
2571 Import(this.importKeyword, StringNode uri, NodeList conditionalUris, 2608 Import(this.importKeyword, StringNode uri, NodeList conditionalUris,
2572 this.prefix, NodeList combinators, 2609 this.prefix, NodeList combinators, List<MetadataAnnotation> metadata,
2573 List<MetadataAnnotation> metadata, 2610 {this.isDeferred})
2574 {this.isDeferred})
2575 : super(uri, conditionalUris, combinators, metadata); 2611 : super(uri, conditionalUris, combinators, metadata);
2576 2612
2577 bool get isImport => true; 2613 bool get isImport => true;
2578 2614
2579 Import asImport() => this; 2615 Import asImport() => this;
2580 2616
2581 accept(Visitor visitor) => visitor.visitImport(this); 2617 accept(Visitor visitor) => visitor.visitImport(this);
2582 2618
2583 accept1(Visitor1 visitor, arg) => visitor.visitImport(this, arg); 2619 accept1(Visitor1 visitor, arg) => visitor.visitImport(this, arg);
2584 2620
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 /** 2718 /**
2683 * An [:export:] library tag. 2719 * An [:export:] library tag.
2684 * 2720 *
2685 * An export tag is dependency on another library where the exported identifiers 2721 * An export tag is dependency on another library where the exported identifiers
2686 * are put into the export scope of the exporting library. The export scope is 2722 * are put into the export scope of the exporting library. The export scope is
2687 * not visible inside the library. 2723 * not visible inside the library.
2688 */ 2724 */
2689 class Export extends LibraryDependency { 2725 class Export extends LibraryDependency {
2690 final Token exportKeyword; 2726 final Token exportKeyword;
2691 2727
2692 Export(this.exportKeyword, 2728 Export(this.exportKeyword, StringNode uri, NodeList conditionalUris,
2693 StringNode uri, 2729 NodeList combinators, List<MetadataAnnotation> metadata)
2694 NodeList conditionalUris,
2695 NodeList combinators,
2696 List<MetadataAnnotation> metadata)
2697 : super(uri, conditionalUris, combinators, metadata); 2730 : super(uri, conditionalUris, combinators, metadata);
2698 2731
2699 bool get isExport => true; 2732 bool get isExport => true;
2700 2733
2701 Export asExport() => this; 2734 Export asExport() => this;
2702 2735
2703 accept(Visitor visitor) => visitor.visitExport(this); 2736 accept(Visitor visitor) => visitor.visitExport(this);
2704 2737
2705 accept1(Visitor1 visitor, arg) => visitor.visitExport(this, arg); 2738 accept1(Visitor1 visitor, arg) => visitor.visitExport(this, arg);
2706 2739
(...skipping 15 matching lines...) Expand all
2722 return uri.getEndToken().next; 2755 return uri.getEndToken().next;
2723 } 2756 }
2724 } 2757 }
2725 2758
2726 class Part extends LibraryTag { 2759 class Part extends LibraryTag {
2727 final StringNode uri; 2760 final StringNode uri;
2728 2761
2729 final Token partKeyword; 2762 final Token partKeyword;
2730 2763
2731 Part(this.partKeyword, this.uri, List<MetadataAnnotation> metadata) 2764 Part(this.partKeyword, this.uri, List<MetadataAnnotation> metadata)
2732 : super(metadata); 2765 : super(metadata);
2733 2766
2734 bool get isPart => true; 2767 bool get isPart => true;
2735 2768
2736 Part asPart() => this; 2769 Part asPart() => this;
2737 2770
2738 accept(Visitor visitor) => visitor.visitPart(this); 2771 accept(Visitor visitor) => visitor.visitPart(this);
2739 2772
2740 accept1(Visitor1 visitor, arg) => visitor.visitPart(this, arg); 2773 accept1(Visitor1 visitor, arg) => visitor.visitPart(this, arg);
2741 2774
2742 visitChildren(Visitor visitor) => uri.accept(visitor); 2775 visitChildren(Visitor visitor) => uri.accept(visitor);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2805 class Typedef extends Node { 2838 class Typedef extends Node {
2806 final TypeAnnotation returnType; 2839 final TypeAnnotation returnType;
2807 final Identifier name; 2840 final Identifier name;
2808 final NodeList typeParameters; 2841 final NodeList typeParameters;
2809 final NodeList formals; 2842 final NodeList formals;
2810 2843
2811 final Token typedefKeyword; 2844 final Token typedefKeyword;
2812 final Token endToken; 2845 final Token endToken;
2813 2846
2814 Typedef(this.returnType, this.name, this.typeParameters, this.formals, 2847 Typedef(this.returnType, this.name, this.typeParameters, this.formals,
2815 this.typedefKeyword, this.endToken); 2848 this.typedefKeyword, this.endToken);
2816 2849
2817 Typedef asTypedef() => this; 2850 Typedef asTypedef() => this;
2818 2851
2819 accept(Visitor visitor) => visitor.visitTypedef(this); 2852 accept(Visitor visitor) => visitor.visitTypedef(this);
2820 2853
2821 accept1(Visitor1 visitor, arg) => visitor.visitTypedef(this, arg); 2854 accept1(Visitor1 visitor, arg) => visitor.visitTypedef(this, arg);
2822 2855
2823 visitChildren(Visitor visitor) { 2856 visitChildren(Visitor visitor) {
2824 if (returnType != null) returnType.accept(visitor); 2857 if (returnType != null) returnType.accept(visitor);
2825 name.accept(visitor); 2858 name.accept(visitor);
(...skipping 15 matching lines...) Expand all
2841 2874
2842 class TryStatement extends Statement { 2875 class TryStatement extends Statement {
2843 final Block tryBlock; 2876 final Block tryBlock;
2844 final NodeList catchBlocks; 2877 final NodeList catchBlocks;
2845 final Block finallyBlock; 2878 final Block finallyBlock;
2846 2879
2847 final Token tryKeyword; 2880 final Token tryKeyword;
2848 final Token finallyKeyword; 2881 final Token finallyKeyword;
2849 2882
2850 TryStatement(this.tryBlock, this.catchBlocks, this.finallyBlock, 2883 TryStatement(this.tryBlock, this.catchBlocks, this.finallyBlock,
2851 this.tryKeyword, this.finallyKeyword); 2884 this.tryKeyword, this.finallyKeyword);
2852 2885
2853 TryStatement asTryStatement() => this; 2886 TryStatement asTryStatement() => this;
2854 2887
2855 accept(Visitor visitor) => visitor.visitTryStatement(this); 2888 accept(Visitor visitor) => visitor.visitTryStatement(this);
2856 2889
2857 accept1(Visitor1 visitor, arg) => visitor.visitTryStatement(this, arg); 2890 accept1(Visitor1 visitor, arg) => visitor.visitTryStatement(this, arg);
2858 2891
2859 visitChildren(Visitor visitor) { 2892 visitChildren(Visitor visitor) {
2860 tryBlock.accept(visitor); 2893 tryBlock.accept(visitor);
2861 catchBlocks.accept(visitor); 2894 catchBlocks.accept(visitor);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 } 2956 }
2924 2957
2925 class CatchBlock extends Node { 2958 class CatchBlock extends Node {
2926 final TypeAnnotation type; 2959 final TypeAnnotation type;
2927 final NodeList formals; 2960 final NodeList formals;
2928 final Block block; 2961 final Block block;
2929 2962
2930 final Token onKeyword; 2963 final Token onKeyword;
2931 final Token catchKeyword; 2964 final Token catchKeyword;
2932 2965
2933 CatchBlock(this.type, this.formals, this.block, 2966 CatchBlock(
2934 this.onKeyword, this.catchKeyword); 2967 this.type, this.formals, this.block, this.onKeyword, this.catchKeyword);
2935 2968
2936 CatchBlock asCatchBlock() => this; 2969 CatchBlock asCatchBlock() => this;
2937 2970
2938 accept(Visitor visitor) => visitor.visitCatchBlock(this); 2971 accept(Visitor visitor) => visitor.visitCatchBlock(this);
2939 2972
2940 accept1(Visitor1 visitor, arg) => visitor.visitCatchBlock(this, arg); 2973 accept1(Visitor1 visitor, arg) => visitor.visitCatchBlock(this, arg);
2941 2974
2942 Node get exception { 2975 Node get exception {
2943 if (formals == null || formals.nodes.isEmpty) return null; 2976 if (formals == null || formals.nodes.isEmpty) return null;
2944 VariableDefinitions declarations = formals.nodes.head; 2977 VariableDefinitions declarations = formals.nodes.head;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2991 } 3024 }
2992 3025
2993 Token getBeginToken() => token; 3026 Token getBeginToken() => token;
2994 3027
2995 Token getEndToken() => expression.getEndToken(); 3028 Token getEndToken() => expression.getEndToken();
2996 } 3029 }
2997 3030
2998 class Initializers { 3031 class Initializers {
2999 static bool isSuperConstructorCall(Send node) { 3032 static bool isSuperConstructorCall(Send node) {
3000 return (node.receiver == null && node.selector.isSuper()) || 3033 return (node.receiver == null && node.selector.isSuper()) ||
3001 (node.receiver != null && 3034 (node.receiver != null &&
3002 node.receiver.isSuper() && 3035 node.receiver.isSuper() &&
3003 !node.isConditional && 3036 !node.isConditional &&
3004 node.selector.asIdentifier() != null); 3037 node.selector.asIdentifier() != null);
3005 } 3038 }
3006 3039
3007 static bool isConstructorRedirect(Send node) { 3040 static bool isConstructorRedirect(Send node) {
3008 return (node.receiver == null && node.selector.isThis()) || 3041 return (node.receiver == null && node.selector.isThis()) ||
3009 (node.receiver != null && 3042 (node.receiver != null &&
3010 node.receiver.isThis() && 3043 node.receiver.isThis() &&
3011 !node.isConditional && 3044 !node.isConditional &&
3012 node.selector.asIdentifier() != null); 3045 node.selector.asIdentifier() != null);
3013 } 3046 }
3014 } 3047 }
3015 3048
3016 class GetDartStringVisitor extends Visitor<DartString> { 3049 class GetDartStringVisitor extends Visitor<DartString> {
3017 const GetDartStringVisitor(); 3050 const GetDartStringVisitor();
3018 DartString visitNode(Node node) => null; 3051 DartString visitNode(Node node) => null;
3019 DartString visitStringJuxtaposition(StringJuxtaposition node) 3052 DartString visitStringJuxtaposition(StringJuxtaposition node) =>
3020 => node.dartString; 3053 node.dartString;
3021 DartString visitLiteralString(LiteralString node) => node.dartString; 3054 DartString visitLiteralString(LiteralString node) => node.dartString;
3022 } 3055 }
3023 3056
3024 class IsInterpolationVisitor extends Visitor<bool> { 3057 class IsInterpolationVisitor extends Visitor<bool> {
3025 const IsInterpolationVisitor(); 3058 const IsInterpolationVisitor();
3026 bool visitNode(Node node) => false; 3059 bool visitNode(Node node) => false;
3027 bool visitStringInterpolation(StringInterpolation node) => true; 3060 bool visitStringInterpolation(StringInterpolation node) => true;
3028 bool visitStringJuxtaposition(StringJuxtaposition node) 3061 bool visitStringJuxtaposition(StringJuxtaposition node) =>
3029 => node.isInterpolation; 3062 node.isInterpolation;
3030 } 3063 }
3031 3064
3032 /// Erroneous node used to recover from parser errors. Implements various 3065 /// Erroneous node used to recover from parser errors. Implements various
3033 /// interfaces and provides bare minimum of implementation to avoid unnecessary 3066 /// interfaces and provides bare minimum of implementation to avoid unnecessary
3034 /// messages. 3067 /// messages.
3035 class ErrorNode 3068 class ErrorNode extends Node
3036 extends Node
3037 implements FunctionExpression, VariableDefinitions, Typedef { 3069 implements FunctionExpression, VariableDefinitions, Typedef {
3038 final Token token; 3070 final Token token;
3039 final String reason; 3071 final String reason;
3040 final Identifier name; 3072 final Identifier name;
3041 final NodeList definitions; 3073 final NodeList definitions;
3042 3074
3043 ErrorNode.internal(this.token, this.reason, this.name, this.definitions); 3075 ErrorNode.internal(this.token, this.reason, this.name, this.definitions);
3044 3076
3045 factory ErrorNode(Token token, String reason) { 3077 factory ErrorNode(Token token, String reason) {
3046 Identifier name = new Identifier(token); 3078 Identifier name = new Identifier(token);
3047 NodeList definitions = new NodeList( 3079 NodeList definitions =
3048 null, const Link<Node>().prepend(name), null, null); 3080 new NodeList(null, const Link<Node>().prepend(name), null, null);
3049 return new ErrorNode.internal(token, reason, name, definitions); 3081 return new ErrorNode.internal(token, reason, name, definitions);
3050 } 3082 }
3051 3083
3052 Token get beginToken => token; 3084 Token get beginToken => token;
3053 Token get endToken => token; 3085 Token get endToken => token;
3054 3086
3055 Token getBeginToken() => token; 3087 Token getBeginToken() => token;
3056 3088
3057 Token getEndToken() => token; 3089 Token getEndToken() => token;
3058 3090
(...skipping 21 matching lines...) Expand all
3080 3112
3081 // VariableDefinitions. 3113 // VariableDefinitions.
3082 get metadata => null; 3114 get metadata => null;
3083 get type => null; 3115 get type => null;
3084 3116
3085 // Typedef. 3117 // Typedef.
3086 get typeParameters => null; 3118 get typeParameters => null;
3087 get formals => null; 3119 get formals => null;
3088 get typedefKeyword => null; 3120 get typedefKeyword => null;
3089 } 3121 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree/dartstring.dart ('k') | pkg/compiler/lib/src/tree/prettyprint.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698