| 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 | 702 |
| 703 Instantiator visitAwait(Await node) { | 703 Instantiator visitAwait(Await node) { |
| 704 Instantiator makeExpression = visit(node.expression); | 704 Instantiator makeExpression = visit(node.expression); |
| 705 return (arguments) { | 705 return (arguments) { |
| 706 return new Await(makeExpression(arguments)); | 706 return new Await(makeExpression(arguments)); |
| 707 }; | 707 }; |
| 708 } | 708 } |
| 709 } | 709 } |
| 710 | 710 |
| 711 /** | 711 /** |
| 712 * InterpolatedNodeAnalysis extract [InterpolatedNode]s from AST. | 712 * InterpolatedNodeAnalysis determines which AST trees contain |
| 713 * [InterpolatedNode]s, and the names of the named interpolated nodes. |
| 713 */ | 714 */ |
| 714 class InterpolatedNodeAnalysis extends BaseVisitor { | 715 class InterpolatedNodeAnalysis extends BaseVisitor { |
| 715 final Setlet<Node> containsInterpolatedNode = new Setlet<Node>(); | 716 final Set<Node> containsInterpolatedNode = new Set<Node>(); |
| 716 final List<InterpolatedNode> interpolatedNodes = <InterpolatedNode>[]; | 717 final Set<String> holeNames = new Set<String>(); |
| 717 final Setlet<String> holeNames = new Setlet<String>(); | |
| 718 int count = 0; | 718 int count = 0; |
| 719 | 719 |
| 720 InterpolatedNodeAnalysis(); | 720 InterpolatedNodeAnalysis(); |
| 721 | 721 |
| 722 bool containsInterpolatedNodes(Node node) => | 722 bool containsInterpolatedNodes(Node node) => |
| 723 containsInterpolatedNode.contains(node); | 723 containsInterpolatedNode.contains(node); |
| 724 | 724 |
| 725 void visit(Node node) { | 725 void visit(Node node) { |
| 726 node.accept(this); | 726 node.accept(this); |
| 727 } | 727 } |
| 728 | 728 |
| 729 void visitNode(Node node) { | 729 void visitNode(Node node) { |
| 730 int before = count; | 730 int before = count; |
| 731 node.visitChildren(this); | 731 node.visitChildren(this); |
| 732 if (count != before) containsInterpolatedNode.add(node); | 732 if (count != before) containsInterpolatedNode.add(node); |
| 733 return null; | 733 return null; |
| 734 } | 734 } |
| 735 | 735 |
| 736 visitInterpolatedNode(InterpolatedNode node) { | 736 visitInterpolatedNode(InterpolatedNode node) { |
| 737 interpolatedNodes.add(node); | |
| 738 containsInterpolatedNode.add(node); | 737 containsInterpolatedNode.add(node); |
| 739 if (node.isNamed) holeNames.add(node.nameOrPosition); | 738 if (node.isNamed) holeNames.add(node.nameOrPosition); |
| 740 ++count; | 739 ++count; |
| 741 } | 740 } |
| 742 } | 741 } |
| OLD | NEW |