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

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

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

Powered by Google App Engine
This is Rietveld 408576698