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

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

Issue 2567133002: Add support for the new function-type syntax. (Closed)
Patch Set: Remove obsolete named argument. Created 3 years, 11 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
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 '../elements/elements.dart' show MetadataAnnotation; 8 import '../elements/elements.dart' show MetadataAnnotation;
9 import '../resolution/secret_tree_element.dart' 9 import '../resolution/secret_tree_element.dart'
10 show NullTreeElementMixin, StoredTreeElementMixin; 10 show NullTreeElementMixin, StoredTreeElementMixin;
(...skipping 30 matching lines...) Expand all
41 R visitDoWhile(DoWhile node) => visitLoop(node); 41 R visitDoWhile(DoWhile node) => visitLoop(node);
42 R visitEmptyStatement(EmptyStatement node) => visitStatement(node); 42 R visitEmptyStatement(EmptyStatement node) => visitStatement(node);
43 R visitEnum(Enum node) => visitNode(node); 43 R visitEnum(Enum node) => visitNode(node);
44 R visitExport(Export node) => visitLibraryDependency(node); 44 R visitExport(Export node) => visitLibraryDependency(node);
45 R visitExpression(Expression node) => visitNode(node); 45 R visitExpression(Expression node) => visitNode(node);
46 R visitExpressionStatement(ExpressionStatement node) => visitStatement(node); 46 R visitExpressionStatement(ExpressionStatement node) => visitStatement(node);
47 R visitFor(For node) => visitLoop(node); 47 R visitFor(For node) => visitLoop(node);
48 R visitForIn(ForIn node) => visitLoop(node); 48 R visitForIn(ForIn node) => visitLoop(node);
49 R visitFunctionDeclaration(FunctionDeclaration node) => visitStatement(node); 49 R visitFunctionDeclaration(FunctionDeclaration node) => visitStatement(node);
50 R visitFunctionExpression(FunctionExpression node) => visitExpression(node); 50 R visitFunctionExpression(FunctionExpression node) => visitExpression(node);
51 R visitFunctionTypeAnnotation(FunctionTypeAnnotation node) {
52 return visitTypeAnnotation(node);
53 }
54
51 R visitGotoStatement(GotoStatement node) => visitStatement(node); 55 R visitGotoStatement(GotoStatement node) => visitStatement(node);
52 R visitIdentifier(Identifier node) => visitExpression(node); 56 R visitIdentifier(Identifier node) => visitExpression(node);
53 R visitImport(Import node) => visitLibraryDependency(node); 57 R visitImport(Import node) => visitLibraryDependency(node);
54 R visitIf(If node) => visitStatement(node); 58 R visitIf(If node) => visitStatement(node);
55 R visitLabel(Label node) => visitNode(node); 59 R visitLabel(Label node) => visitNode(node);
56 R visitLabeledStatement(LabeledStatement node) => visitStatement(node); 60 R visitLabeledStatement(LabeledStatement node) => visitStatement(node);
57 R visitLibraryDependency(LibraryDependency node) => visitLibraryTag(node); 61 R visitLibraryDependency(LibraryDependency node) => visitLibraryTag(node);
58 R visitLibraryName(LibraryName node) => visitLibraryTag(node); 62 R visitLibraryName(LibraryName node) => visitLibraryTag(node);
59 R visitLibraryTag(LibraryTag node) => visitNode(node); 63 R visitLibraryTag(LibraryTag node) => visitNode(node);
60 R visitLiteral(Literal node) => visitExpression(node); 64 R visitLiteral(Literal node) => visitExpression(node);
(...skipping 11 matching lines...) Expand all
72 R visitMetadata(Metadata node) => visitNode(node); 76 R visitMetadata(Metadata node) => visitNode(node);
73 R visitMixinApplication(MixinApplication node) => visitNode(node); 77 R visitMixinApplication(MixinApplication node) => visitNode(node);
74 R visitModifiers(Modifiers node) => visitNode(node); 78 R visitModifiers(Modifiers node) => visitNode(node);
75 R visitNamedArgument(NamedArgument node) => visitExpression(node); 79 R visitNamedArgument(NamedArgument node) => visitExpression(node);
76 R visitNamedMixinApplication(NamedMixinApplication node) { 80 R visitNamedMixinApplication(NamedMixinApplication node) {
77 return visitMixinApplication(node); 81 return visitMixinApplication(node);
78 } 82 }
79 83
80 R visitNewExpression(NewExpression node) => visitExpression(node); 84 R visitNewExpression(NewExpression node) => visitExpression(node);
81 R visitNodeList(NodeList node) => visitNode(node); 85 R visitNodeList(NodeList node) => visitNode(node);
86 R visitNominalTypeAnnotation(NominalTypeAnnotation node) {
87 return visitTypeAnnotation(node);
88 }
89
82 R visitOperator(Operator node) => visitIdentifier(node); 90 R visitOperator(Operator node) => visitIdentifier(node);
83 R visitParenthesizedExpression(ParenthesizedExpression node) { 91 R visitParenthesizedExpression(ParenthesizedExpression node) {
84 return visitExpression(node); 92 return visitExpression(node);
85 } 93 }
86 94
87 R visitPart(Part node) => visitLibraryTag(node); 95 R visitPart(Part node) => visitLibraryTag(node);
88 R visitPartOf(PartOf node) => visitNode(node); 96 R visitPartOf(PartOf node) => visitNode(node);
89 R visitPostfix(Postfix node) => visitNodeList(node); 97 R visitPostfix(Postfix node) => visitNodeList(node);
90 R visitPrefix(Prefix node) => visitNodeList(node); 98 R visitPrefix(Prefix node) => visitNodeList(node);
91 R visitRedirectingFactoryBody(RedirectingFactoryBody node) { 99 R visitRedirectingFactoryBody(RedirectingFactoryBody node) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 R visitFor(For node, A arg) => visitLoop(node, arg); 177 R visitFor(For node, A arg) => visitLoop(node, arg);
170 R visitForIn(ForIn node, A arg) => visitLoop(node, arg); 178 R visitForIn(ForIn node, A arg) => visitLoop(node, arg);
171 R visitFunctionDeclaration(FunctionDeclaration node, A arg) { 179 R visitFunctionDeclaration(FunctionDeclaration node, A arg) {
172 return visitStatement(node, arg); 180 return visitStatement(node, arg);
173 } 181 }
174 182
175 R visitFunctionExpression(FunctionExpression node, A arg) { 183 R visitFunctionExpression(FunctionExpression node, A arg) {
176 return visitExpression(node, arg); 184 return visitExpression(node, arg);
177 } 185 }
178 186
187 R visitFunctionTypeAnnotation(FunctionTypeAnnotation node, A arg) {
188 return visitTypeAnnotation(node, arg);
189 }
190
179 R visitGotoStatement(GotoStatement node, A arg) { 191 R visitGotoStatement(GotoStatement node, A arg) {
180 return visitStatement(node, arg); 192 return visitStatement(node, arg);
181 } 193 }
182 194
183 R visitIdentifier(Identifier node, A arg) { 195 R visitIdentifier(Identifier node, A arg) {
184 return visitExpression(node, arg); 196 return visitExpression(node, arg);
185 } 197 }
186 198
187 R visitImport(Import node, A arg) { 199 R visitImport(Import node, A arg) {
188 return visitLibraryDependency(node, arg); 200 return visitLibraryDependency(node, arg);
(...skipping 29 matching lines...) Expand all
218 R visitMetadata(Metadata node, A arg) => visitNode(node, arg); 230 R visitMetadata(Metadata node, A arg) => visitNode(node, arg);
219 R visitMixinApplication(MixinApplication node, A arg) => visitNode(node, arg); 231 R visitMixinApplication(MixinApplication node, A arg) => visitNode(node, arg);
220 R visitModifiers(Modifiers node, A arg) => visitNode(node, arg); 232 R visitModifiers(Modifiers node, A arg) => visitNode(node, arg);
221 R visitNamedArgument(NamedArgument node, A arg) => visitExpression(node, arg); 233 R visitNamedArgument(NamedArgument node, A arg) => visitExpression(node, arg);
222 R visitNamedMixinApplication(NamedMixinApplication node, A arg) { 234 R visitNamedMixinApplication(NamedMixinApplication node, A arg) {
223 return visitMixinApplication(node, arg); 235 return visitMixinApplication(node, arg);
224 } 236 }
225 237
226 R visitNewExpression(NewExpression node, A arg) => visitExpression(node, arg); 238 R visitNewExpression(NewExpression node, A arg) => visitExpression(node, arg);
227 R visitNodeList(NodeList node, A arg) => visitNode(node, arg); 239 R visitNodeList(NodeList node, A arg) => visitNode(node, arg);
240 R visitNominalTypeAnnotation(NominalTypeAnnotation node, A arg) {
241 visitTypeAnnotation(node, arg);
242 }
243
228 R visitOperator(Operator node, A arg) => visitIdentifier(node, arg); 244 R visitOperator(Operator node, A arg) => visitIdentifier(node, arg);
229 R visitParenthesizedExpression(ParenthesizedExpression node, A arg) { 245 R visitParenthesizedExpression(ParenthesizedExpression node, A arg) {
230 return visitExpression(node, arg); 246 return visitExpression(node, arg);
231 } 247 }
232 248
233 R visitPart(Part node, A arg) => visitLibraryTag(node, arg); 249 R visitPart(Part node, A arg) => visitLibraryTag(node, arg);
234 R visitPartOf(PartOf node, A arg) => visitNode(node, arg); 250 R visitPartOf(PartOf node, A arg) => visitNode(node, arg);
235 R visitPostfix(Postfix node, A arg) => visitNodeList(node, arg); 251 R visitPostfix(Postfix node, A arg) => visitNodeList(node, arg);
236 R visitPrefix(Prefix node, A arg) => visitNodeList(node, arg); 252 R visitPrefix(Prefix node, A arg) => visitNodeList(node, arg);
237 R visitRedirectingFactoryBody(RedirectingFactoryBody node, A arg) { 253 R visitRedirectingFactoryBody(RedirectingFactoryBody node, A arg) {
(...skipping 15 matching lines...) Expand all
253 } 269 }
254 270
255 R visitSwitchCase(SwitchCase node, A arg) => visitNode(node, arg); 271 R visitSwitchCase(SwitchCase node, A arg) => visitNode(node, arg);
256 R visitSwitchStatement(SwitchStatement node, A arg) { 272 R visitSwitchStatement(SwitchStatement node, A arg) {
257 return visitStatement(node, arg); 273 return visitStatement(node, arg);
258 } 274 }
259 275
260 R visitLiteralSymbol(LiteralSymbol node, A arg) => visitExpression(node, arg); 276 R visitLiteralSymbol(LiteralSymbol node, A arg) => visitExpression(node, arg);
261 R visitThrow(Throw node, A arg) => visitExpression(node, arg); 277 R visitThrow(Throw node, A arg) => visitExpression(node, arg);
262 R visitTryStatement(TryStatement node, A arg) => visitStatement(node, arg); 278 R visitTryStatement(TryStatement node, A arg) => visitStatement(node, arg);
263 R visitTypeAnnotation(TypeAnnotation node, A arg) => visitNode(node, arg);
264 R visitTypedef(Typedef node, A arg) => visitNode(node, arg); 279 R visitTypedef(Typedef node, A arg) => visitNode(node, arg);
280 R visitTypeAnnotation(TypeAnnotation node, A arg) => visistNode(node, arg);
Johnni Winther 2017/01/02 12:46:53 `visistNode` -> `visitNode`
floitsch 2017/01/02 13:48:48 ouch. thanks. done.
265 R visitTypeVariable(TypeVariable node, A arg) => visitNode(node, arg); 281 R visitTypeVariable(TypeVariable node, A arg) => visitNode(node, arg);
266 R visitVariableDefinitions(VariableDefinitions node, A arg) { 282 R visitVariableDefinitions(VariableDefinitions node, A arg) {
267 return visitStatement(node, arg); 283 return visitStatement(node, arg);
268 } 284 }
269 285
270 R visitWhile(While node, A arg) => visitLoop(node, arg); 286 R visitWhile(While node, A arg) => visitLoop(node, arg);
271 R visitYield(Yield node, A arg) => visitStatement(node, arg); 287 R visitYield(Yield node, A arg) => visitStatement(node, arg);
272 } 288 }
273 289
274 Token firstBeginToken(Node first, Node second) { 290 Token firstBeginToken(Node first, Node second) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 ErrorExpression asErrorExpression() => null; 369 ErrorExpression asErrorExpression() => null;
354 Export asExport() => null; 370 Export asExport() => null;
355 Expression asExpression() => null; 371 Expression asExpression() => null;
356 ExpressionStatement asExpressionStatement() => null; 372 ExpressionStatement asExpressionStatement() => null;
357 For asFor() => null; 373 For asFor() => null;
358 SyncForIn asSyncForIn() => null; 374 SyncForIn asSyncForIn() => null;
359 AsyncForIn asAsyncForIn() => null; 375 AsyncForIn asAsyncForIn() => null;
360 ForIn asForIn() => null; 376 ForIn asForIn() => null;
361 FunctionDeclaration asFunctionDeclaration() => null; 377 FunctionDeclaration asFunctionDeclaration() => null;
362 FunctionExpression asFunctionExpression() => null; 378 FunctionExpression asFunctionExpression() => null;
379 FunctionTypeAnnotation asFunctionTypeAnnotation() => null;
363 Identifier asIdentifier() => null; 380 Identifier asIdentifier() => null;
364 If asIf() => null; 381 If asIf() => null;
365 Import asImport() => null; 382 Import asImport() => null;
366 Label asLabel() => null; 383 Label asLabel() => null;
367 LabeledStatement asLabeledStatement() => null; 384 LabeledStatement asLabeledStatement() => null;
368 LibraryName asLibraryName() => null; 385 LibraryName asLibraryName() => null;
369 LibraryDependency asLibraryDependency() => null; 386 LibraryDependency asLibraryDependency() => null;
370 LiteralBool asLiteralBool() => null; 387 LiteralBool asLiteralBool() => null;
371 LiteralDouble asLiteralDouble() => null; 388 LiteralDouble asLiteralDouble() => null;
372 LiteralInt asLiteralInt() => null; 389 LiteralInt asLiteralInt() => null;
373 LiteralList asLiteralList() => null; 390 LiteralList asLiteralList() => null;
374 LiteralMap asLiteralMap() => null; 391 LiteralMap asLiteralMap() => null;
375 LiteralMapEntry asLiteralMapEntry() => null; 392 LiteralMapEntry asLiteralMapEntry() => null;
376 LiteralNull asLiteralNull() => null; 393 LiteralNull asLiteralNull() => null;
377 LiteralString asLiteralString() => null; 394 LiteralString asLiteralString() => null;
378 LiteralSymbol asLiteralSymbol() => null; 395 LiteralSymbol asLiteralSymbol() => null;
379 Metadata asMetadata() => null; 396 Metadata asMetadata() => null;
380 MixinApplication asMixinApplication() => null; 397 MixinApplication asMixinApplication() => null;
381 Modifiers asModifiers() => null; 398 Modifiers asModifiers() => null;
382 NamedArgument asNamedArgument() => null; 399 NamedArgument asNamedArgument() => null;
383 NamedMixinApplication asNamedMixinApplication() => null; 400 NamedMixinApplication asNamedMixinApplication() => null;
384 NewExpression asNewExpression() => null; 401 NewExpression asNewExpression() => null;
385 NodeList asNodeList() => null; 402 NodeList asNodeList() => null;
403 NominalTypeAnnotation asNominalTypeAnnotation() => null;
386 Operator asOperator() => null; 404 Operator asOperator() => null;
387 ParenthesizedExpression asParenthesizedExpression() => null; 405 ParenthesizedExpression asParenthesizedExpression() => null;
388 Part asPart() => null; 406 Part asPart() => null;
389 PartOf asPartOf() => null; 407 PartOf asPartOf() => null;
390 RedirectingFactoryBody asRedirectingFactoryBody() => null; 408 RedirectingFactoryBody asRedirectingFactoryBody() => null;
391 Rethrow asRethrow() => null; 409 Rethrow asRethrow() => null;
392 Return asReturn() => null; 410 Return asReturn() => null;
393 Send asSend() => null; 411 Send asSend() => null;
394 SendSet asSendSet() => null; 412 SendSet asSendSet() => null;
395 Statement asStatement() => null; 413 Statement asStatement() => null;
396 StringInterpolation asStringInterpolation() => null; 414 StringInterpolation asStringInterpolation() => null;
397 StringInterpolationPart asStringInterpolationPart() => null; 415 StringInterpolationPart asStringInterpolationPart() => null;
398 StringJuxtaposition asStringJuxtaposition() => null; 416 StringJuxtaposition asStringJuxtaposition() => null;
399 StringNode asStringNode() => null; 417 StringNode asStringNode() => null;
400 SwitchCase asSwitchCase() => null; 418 SwitchCase asSwitchCase() => null;
401 SwitchStatement asSwitchStatement() => null; 419 SwitchStatement asSwitchStatement() => null;
402 Throw asThrow() => null; 420 Throw asThrow() => null;
403 TryStatement asTryStatement() => null; 421 TryStatement asTryStatement() => null;
404 TypeAnnotation asTypeAnnotation() => null;
405 TypeVariable asTypeVariable() => null; 422 TypeVariable asTypeVariable() => null;
406 Typedef asTypedef() => null; 423 Typedef asTypedef() => null;
407 VariableDefinitions asVariableDefinitions() => null; 424 VariableDefinitions asVariableDefinitions() => null;
408 While asWhile() => null; 425 While asWhile() => null;
409 Yield asYield() => null; 426 Yield asYield() => null;
410 427
411 bool isValidBreakTarget() => false; 428 bool isValidBreakTarget() => false;
412 bool isValidContinueTarget() => false; 429 bool isValidContinueTarget() => false;
413 bool isThis() => false; 430 bool isThis() => false;
414 bool isSuper() => false; 431 bool isSuper() => false;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 token = name.getEndToken(); 496 token = name.getEndToken();
480 } 497 }
481 assert(invariant(beginToken, token != null)); 498 assert(invariant(beginToken, token != null));
482 return token; 499 return token;
483 } 500 }
484 501
485 Token getEndToken() => endToken; 502 Token getEndToken() => endToken;
486 } 503 }
487 504
488 class MixinApplication extends Node { 505 class MixinApplication extends Node {
489 final TypeAnnotation superclass; 506 final NominalTypeAnnotation superclass;
490 final NodeList mixins; 507 final NodeList mixins;
491 508
492 MixinApplication(this.superclass, this.mixins); 509 MixinApplication(this.superclass, this.mixins);
493 510
494 MixinApplication asMixinApplication() => this; 511 MixinApplication asMixinApplication() => this;
495 512
496 accept(Visitor visitor) => visitor.visitMixinApplication(this); 513 accept(Visitor visitor) => visitor.visitMixinApplication(this);
497 514
498 accept1(Visitor1 visitor, arg) => visitor.visitMixinApplication(this, arg); 515 accept1(Visitor1 visitor, arg) => visitor.visitMixinApplication(this, arg);
499 516
500 visitChildren(Visitor visitor) { 517 visitChildren(Visitor visitor) {
501 if (superclass != null) superclass.accept(visitor); 518 if (superclass != null) superclass.accept(visitor);
502 if (mixins != null) mixins.accept(visitor); 519 if (mixins != null) mixins.accept(visitor);
503 } 520 }
504 521
505 visitChildren1(Visitor1 visitor, arg) { 522 visitChildren1(Visitor1 visitor, arg) {
506 if (superclass != null) superclass.accept1(visitor, arg); 523 if (superclass != null) superclass.accept1(visitor, arg);
507 if (mixins != null) mixins.accept1(visitor, arg); 524 if (mixins != null) mixins.accept1(visitor, arg);
508 } 525 }
509 526
510 Token getBeginToken() => superclass.getBeginToken(); 527 Token getBeginToken() => superclass.getBeginToken();
511 Token getEndToken() => mixins.getEndToken(); 528 Token getEndToken() => mixins.getEndToken();
512 } 529 }
513 530
514 // TODO(kasperl): Let this share some structure with the typedef for function
515 // type aliases?
516 class NamedMixinApplication extends Node implements MixinApplication { 531 class NamedMixinApplication extends Node implements MixinApplication {
517 final Identifier name; 532 final Identifier name;
518 final NodeList typeParameters; 533 final NodeList typeParameters;
519 534
520 final Modifiers modifiers; 535 final Modifiers modifiers;
521 final MixinApplication mixinApplication; 536 final MixinApplication mixinApplication;
522 final NodeList interfaces; 537 final NodeList interfaces;
523 538
524 final Token classKeyword; 539 final Token classKeyword;
525 final Token endToken; 540 final Token endToken;
526 541
527 NamedMixinApplication(this.name, this.typeParameters, this.modifiers, 542 NamedMixinApplication(this.name, this.typeParameters, this.modifiers,
528 this.mixinApplication, this.interfaces, this.classKeyword, this.endToken); 543 this.mixinApplication, this.interfaces, this.classKeyword, this.endToken);
529 544
530 TypeAnnotation get superclass => mixinApplication.superclass; 545 NominalTypeAnnotation get superclass => mixinApplication.superclass;
531 NodeList get mixins => mixinApplication.mixins; 546 NodeList get mixins => mixinApplication.mixins;
532 547
533 MixinApplication asMixinApplication() => this; 548 MixinApplication asMixinApplication() => this;
534 NamedMixinApplication asNamedMixinApplication() => this; 549 NamedMixinApplication asNamedMixinApplication() => this;
535 550
536 accept(Visitor visitor) => visitor.visitNamedMixinApplication(this); 551 accept(Visitor visitor) => visitor.visitNamedMixinApplication(this);
537 552
538 accept1(Visitor1 visitor, arg) { 553 accept1(Visitor1 visitor, arg) {
539 return visitor.visitNamedMixinApplication(this, arg); 554 return visitor.visitNamedMixinApplication(this, arg);
540 } 555 }
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 accept1(Visitor1 visitor, arg) => visitor.visitRethrow(this, arg); 1728 accept1(Visitor1 visitor, arg) => visitor.visitRethrow(this, arg);
1714 1729
1715 visitChildren(Visitor visitor) {} 1730 visitChildren(Visitor visitor) {}
1716 1731
1717 visitChildren1(Visitor1 visitor, arg) {} 1732 visitChildren1(Visitor1 visitor, arg) {}
1718 1733
1719 Token getBeginToken() => throwToken; 1734 Token getBeginToken() => throwToken;
1720 Token getEndToken() => endToken; 1735 Token getEndToken() => endToken;
1721 } 1736 }
1722 1737
1723 class TypeAnnotation extends Node { 1738 abstract class TypeAnnotation extends Node {
1739 }
1740
1741 class NominalTypeAnnotation extends TypeAnnotation {
1724 final Expression typeName; 1742 final Expression typeName;
1725 final NodeList typeArguments; 1743 final NodeList typeArguments;
1726 1744
1727 TypeAnnotation(Expression this.typeName, NodeList this.typeArguments); 1745 NominalTypeAnnotation(this.typeName, this.typeArguments);
1728 1746
1729 TypeAnnotation asTypeAnnotation() => this; 1747 NominalTypeAnnotation asNominalTypeAnnotation() => this;
1730 1748
1731 accept(Visitor visitor) => visitor.visitTypeAnnotation(this); 1749 accept(Visitor visitor) => visitor.visitNominalTypeAnnotation(this);
1732 1750
1733 accept1(Visitor1 visitor, arg) => visitor.visitTypeAnnotation(this, arg); 1751 accept1(Visitor1 visitor, arg) {
1752 return visitor.visitNominalTypeAnnotation(this, arg);
1753 }
1734 1754
1735 visitChildren(Visitor visitor) { 1755 visitChildren(Visitor visitor) {
1736 typeName.accept(visitor); 1756 typeName.accept(visitor);
1737 if (typeArguments != null) typeArguments.accept(visitor); 1757 if (typeArguments != null) typeArguments.accept(visitor);
1738 } 1758 }
1739 1759
1740 visitChildren1(Visitor1 visitor, arg) { 1760 visitChildren1(Visitor1 visitor, arg) {
1741 typeName.accept1(visitor, arg); 1761 typeName.accept1(visitor, arg);
1742 if (typeArguments != null) typeArguments.accept1(visitor, arg); 1762 if (typeArguments != null) typeArguments.accept1(visitor, arg);
1743 } 1763 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 } 1839 }
1820 1840
1821 Token getBeginToken() { 1841 Token getBeginToken() {
1822 var token = firstBeginToken(modifiers, type); 1842 var token = firstBeginToken(modifiers, type);
1823 if (token == null) { 1843 if (token == null) {
1824 token = definitions.getBeginToken(); 1844 token = definitions.getBeginToken();
1825 } 1845 }
1826 return token; 1846 return token;
1827 } 1847 }
1828 1848
1829 Token getEndToken() => definitions.getEndToken(); 1849 Token getEndToken() {
1850 var result = definitions.getEndToken();
1851 if (result != null) return result;
1852 assert(definitions.nodes.length == 1);
1853 assert(definitions.nodes.last == null);
1854 return type.getEndToken();
1855 }
1830 } 1856 }
1831 1857
1832 abstract class Loop extends Statement { 1858 abstract class Loop extends Statement {
1833 Expression get condition; 1859 Expression get condition;
1834 final Statement body; 1860 final Statement body;
1835 1861
1836 Loop(this.body); 1862 Loop(this.body);
1837 1863
1838 bool isValidContinueTarget() => true; 1864 bool isValidContinueTarget() => true;
1839 } 1865 }
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
2847 visitChildren(Visitor visitor) => identifiers.accept(visitor); 2873 visitChildren(Visitor visitor) => identifiers.accept(visitor);
2848 2874
2849 visitChildren1(Visitor1 visitor, arg) => identifiers.accept1(visitor, arg); 2875 visitChildren1(Visitor1 visitor, arg) => identifiers.accept1(visitor, arg);
2850 2876
2851 Token getBeginToken() => keywordToken; 2877 Token getBeginToken() => keywordToken;
2852 2878
2853 Token getEndToken() => identifiers.getEndToken(); 2879 Token getEndToken() => identifiers.getEndToken();
2854 } 2880 }
2855 2881
2856 class Typedef extends Node { 2882 class Typedef extends Node {
2883 final bool isGeneralizedTypeAlias;
2884
2885 /// Parameters to the template.
2886 ///
2887 /// For example, `T` and `S` are template parameters in the following
2888 /// typedef: `typedef F<S, T> = Function(S, T)`, or, in the inlined syntax,
2889 /// `typedef F<S, T>(S x, T y)`.
2890 final NodeList templateParameters;
2891
2857 final TypeAnnotation returnType; 2892 final TypeAnnotation returnType;
2858 final Identifier name; 2893 final Identifier name;
2894 /// The generic type parameters to the function type.
2895 ///
2896 /// For example `A` and `B` (but not `T`) are type parameters in
2897 /// `typedef F<T> = Function<A, B>(A, B, T)`;
2859 final NodeList typeParameters; 2898 final NodeList typeParameters;
2860 final NodeList formals; 2899 final NodeList formals;
2861 2900
2862 final Token typedefKeyword; 2901 final Token typedefKeyword;
2863 final Token endToken; 2902 final Token endToken;
2864 2903
2865 Typedef(this.returnType, this.name, this.typeParameters, this.formals, 2904 Typedef(this.isGeneralizedTypeAlias, this.templateParameters, this.returnType,
2866 this.typedefKeyword, this.endToken); 2905 this.name, this.typeParameters, this.formals, this.typedefKeyword,
2906 this.endToken);
2867 2907
2868 Typedef asTypedef() => this; 2908 Typedef asTypedef() => this;
2869 2909
2870 accept(Visitor visitor) => visitor.visitTypedef(this); 2910 accept(Visitor visitor) => visitor.visitTypedef(this);
2871 2911
2872 accept1(Visitor1 visitor, arg) => visitor.visitTypedef(this, arg); 2912 accept1(Visitor1 visitor, arg) => visitor.visitTypedef(this, arg);
2873 2913
2874 visitChildren(Visitor visitor) { 2914 visitChildren(Visitor visitor) {
2915 if (templateParameters != null) templateParameters.accept(visitor);
2875 if (returnType != null) returnType.accept(visitor); 2916 if (returnType != null) returnType.accept(visitor);
2876 name.accept(visitor); 2917 name.accept(visitor);
2877 if (typeParameters != null) typeParameters.accept(visitor); 2918 if (typeParameters != null) typeParameters.accept(visitor);
2878 formals.accept(visitor); 2919 formals.accept(visitor);
2879 } 2920 }
2880 2921
2881 visitChildren1(Visitor1 visitor, arg) { 2922 visitChildren1(Visitor1 visitor, arg) {
2923 if (templateParameters != null) templateParameters.accept1(visitor, arg);
2882 if (returnType != null) returnType.accept1(visitor, arg); 2924 if (returnType != null) returnType.accept1(visitor, arg);
2883 name.accept1(visitor, arg); 2925 name.accept1(visitor, arg);
2884 if (typeParameters != null) typeParameters.accept1(visitor, arg); 2926 if (typeParameters != null) typeParameters.accept1(visitor, arg);
2885 formals.accept1(visitor, arg); 2927 formals.accept1(visitor, arg);
2886 } 2928 }
2887 2929
2888 Token getBeginToken() => typedefKeyword; 2930 Token getBeginToken() => typedefKeyword;
2889 2931
2890 Token getEndToken() => endToken; 2932 Token getEndToken() => endToken;
2891 } 2933 }
2892 2934
2935 class FunctionTypeAnnotation extends TypeAnnotation {
2936 final TypeAnnotation returnType;
2937 final Token functionToken;
2938 final NodeList typeParameters;
2939 final NodeList formals;
2940
2941 FunctionTypeAnnotation(
2942 this.returnType, this.functionToken, this.typeParameters, this.formals);
2943
2944 FunctionTypeAnnotation asFunctionTypeAnnotation() => this;
2945
2946 accept(Visitor visitor) => visitor.visitFunctionTypeAnnotation(this);
2947
2948 accept1(Visitor1 visitor, arg) {
2949 return visitor.visitFunctionTypeAnnotation(this, arg);
2950 }
2951
2952 visitChildren(Visitor visitor) {
2953 if (returnType != null) returnType.accept(visitor);
2954 if (typeParameters != null) typeParameters.accept(visitor);
2955 formals.accept(visitor);
2956 }
2957
2958 visitChildren1(Visitor1 visitor, arg) {
2959 if (returnType != null) returnType.accept1(visitor, arg);
2960 if (typeParameters != null) typeParameters.accept1(visitor, arg);
2961 formals.accept1(visitor, arg);
2962 }
2963
2964 Token getBeginToken() {
2965 if (returnType != null) return returnType.getBeginToken();
2966 return functionToken;
2967 }
2968
2969 Token getEndToken() => formals.getEndToken();
2970 }
2971
2893 class TryStatement extends Statement { 2972 class TryStatement extends Statement {
2894 final Block tryBlock; 2973 final Block tryBlock;
2895 final NodeList catchBlocks; 2974 final NodeList catchBlocks;
2896 final Block finallyBlock; 2975 final Block finallyBlock;
2897 2976
2898 final Token tryKeyword; 2977 final Token tryKeyword;
2899 final Token finallyKeyword; 2978 final Token finallyKeyword;
2900 2979
2901 TryStatement(this.tryBlock, this.catchBlocks, this.finallyBlock, 2980 TryStatement(this.tryBlock, this.catchBlocks, this.finallyBlock,
2902 this.tryKeyword, this.finallyKeyword); 2981 this.tryKeyword, this.finallyKeyword);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
3127 get getOrSet => null; 3206 get getOrSet => null;
3128 get isRedirectingFactory => false; 3207 get isRedirectingFactory => false;
3129 bool get hasBody => false; 3208 bool get hasBody => false;
3130 bool get hasEmptyBody => false; 3209 bool get hasEmptyBody => false;
3131 3210
3132 // VariableDefinitions. 3211 // VariableDefinitions.
3133 get metadata => null; 3212 get metadata => null;
3134 get type => null; 3213 get type => null;
3135 3214
3136 // Typedef. 3215 // Typedef.
3137 get typeParameters => null; 3216 get isGeneralizedTypeAlias => null;
3217 get templateParameters => null;
3138 get formals => null; 3218 get formals => null;
3139 get typedefKeyword => null; 3219 get typedefKeyword => null;
3140 } 3220 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698