OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 part of js; | 5 part of js; |
6 | 6 |
7 class TemplateManager { | 7 class TemplateManager { |
8 Map<String, Template> expressionTemplates = new Map<String, Template>(); | 8 Map<String, Template> expressionTemplates = new Map<String, Template>(); |
9 Map<String, Template> statementTemplates = new Map<String, Template>(); | 9 Map<String, Template> statementTemplates = new Map<String, Template>(); |
10 | 10 |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 (arguments) => new Continue(node.targetLabel); | 428 (arguments) => new Continue(node.targetLabel); |
429 | 429 |
430 Instantiator visitBreak(Break node) => | 430 Instantiator visitBreak(Break node) => |
431 (arguments) => new Break(node.targetLabel); | 431 (arguments) => new Break(node.targetLabel); |
432 | 432 |
433 Instantiator visitReturn(Return node) { | 433 Instantiator visitReturn(Return node) { |
434 Instantiator makeExpression = visitNullable(node.value); | 434 Instantiator makeExpression = visitNullable(node.value); |
435 return (arguments) => new Return(makeExpression(arguments)); | 435 return (arguments) => new Return(makeExpression(arguments)); |
436 } | 436 } |
437 | 437 |
| 438 Instantiator visitYield(Yield node) { |
| 439 Instantiator makeExpression = visit(node.expression); |
| 440 return (arguments) => new Yield(makeExpression(arguments), node.hasStar); |
| 441 } |
| 442 |
438 Instantiator visitThrow(Throw node) { | 443 Instantiator visitThrow(Throw node) { |
439 Instantiator makeExpression = visit(node.expression); | 444 Instantiator makeExpression = visit(node.expression); |
440 return (arguments) => new Throw(makeExpression(arguments)); | 445 return (arguments) => new Throw(makeExpression(arguments)); |
441 } | 446 } |
442 | 447 |
443 Instantiator visitTry(Try node) { | 448 Instantiator visitTry(Try node) { |
444 Instantiator makeBody = visit(node.body); | 449 Instantiator makeBody = visit(node.body); |
445 Instantiator makeCatch = visitNullable(node.catchPart); | 450 Instantiator makeCatch = visitNullable(node.catchPart); |
446 Instantiator makeFinally = visitNullable(node.finallyPart); | 451 Instantiator makeFinally = visitNullable(node.finallyPart); |
447 return (arguments) => new Try( | 452 return (arguments) => new Try( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 }; | 485 }; |
481 } | 486 } |
482 | 487 |
483 Instantiator visitFunctionDeclaration(FunctionDeclaration node) { | 488 Instantiator visitFunctionDeclaration(FunctionDeclaration node) { |
484 Instantiator makeName = visit(node.name); | 489 Instantiator makeName = visit(node.name); |
485 Instantiator makeFunction = visit(node.function); | 490 Instantiator makeFunction = visit(node.function); |
486 return (arguments) => | 491 return (arguments) => |
487 new FunctionDeclaration(makeName(arguments), makeFunction(arguments)); | 492 new FunctionDeclaration(makeName(arguments), makeFunction(arguments)); |
488 } | 493 } |
489 | 494 |
490 Instantiator visitLabeledStatement(LabeledStatement node) => | 495 Instantiator visitLabeledStatement(LabeledStatement node) { |
491 TODO('visitLabeledStatement'); | 496 Instantiator makeBody = visit(node.body); |
| 497 return (arguments) => new LabeledStatement(node.label, makeBody(arguments)); |
| 498 } |
| 499 |
492 Instantiator visitLiteralStatement(LiteralStatement node) => | 500 Instantiator visitLiteralStatement(LiteralStatement node) => |
493 TODO('visitLiteralStatement'); | 501 TODO('visitLiteralStatement'); |
494 Instantiator visitBlob(Blob node) => | 502 Instantiator visitBlob(Blob node) => |
495 TODO('visitBlob'); | 503 TODO('visitBlob'); |
496 Instantiator visitLiteralExpression(LiteralExpression node) => | 504 Instantiator visitLiteralExpression(LiteralExpression node) => |
497 TODO('visitLiteralExpression'); | 505 TODO('visitLiteralExpression'); |
498 | 506 |
499 Instantiator visitVariableDeclarationList(VariableDeclarationList node) { | 507 Instantiator visitVariableDeclarationList(VariableDeclarationList node) { |
500 List<Instantiator> declarationMakers = | 508 List<Instantiator> declarationMakers = |
501 node.declarations.map(visit).toList(); | 509 node.declarations.map(visit).toList(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 return null; | 733 return null; |
726 } | 734 } |
727 | 735 |
728 visitInterpolatedNode(InterpolatedNode node) { | 736 visitInterpolatedNode(InterpolatedNode node) { |
729 interpolatedNodes.add(node); | 737 interpolatedNodes.add(node); |
730 containsInterpolatedNode.add(node); | 738 containsInterpolatedNode.add(node); |
731 if (node.isNamed) holeNames.add(node.nameOrPosition); | 739 if (node.isNamed) holeNames.add(node.nameOrPosition); |
732 ++count; | 740 ++count; |
733 } | 741 } |
734 } | 742 } |
OLD | NEW |