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_ast; | 5 part of js_ast; |
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 118 } |
119 return instantiator(arguments); | 119 return instantiator(arguments); |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 /** | 123 /** |
124 * An Instantiator is a Function that generates a JS AST tree or List of | 124 * An Instantiator is a Function that generates a JS AST tree or List of |
125 * trees. [arguments] is a List for positional templates, or Map for | 125 * trees. [arguments] is a List for positional templates, or Map for |
126 * named templates. | 126 * named templates. |
127 */ | 127 */ |
128 typedef Node Instantiator(var arguments); | 128 typedef Instantiator(var arguments); |
129 | 129 |
130 | 130 |
131 /** | 131 /** |
132 * InstantiatorGeneratorVisitor compiles a template. This class compiles a tree | 132 * InstantiatorGeneratorVisitor compiles a template. This class compiles a tree |
133 * containing [InterpolatedNode]s into a function that will create a copy of the | 133 * containing [InterpolatedNode]s into a function that will create a copy of the |
134 * tree with the interpolated nodes substituted with provided values. | 134 * tree with the interpolated nodes substituted with provided values. |
135 */ | 135 */ |
136 class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> { | 136 class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> { |
137 | 137 |
138 final bool forceCopy; | 138 final bool forceCopy; |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 if (count != before) containsInterpolatedNode.add(node); | 859 if (count != before) containsInterpolatedNode.add(node); |
860 return null; | 860 return null; |
861 } | 861 } |
862 | 862 |
863 visitInterpolatedNode(InterpolatedNode node) { | 863 visitInterpolatedNode(InterpolatedNode node) { |
864 containsInterpolatedNode.add(node); | 864 containsInterpolatedNode.add(node); |
865 if (node.isNamed) holeNames.add(node.nameOrPosition); | 865 if (node.isNamed) holeNames.add(node.nameOrPosition); |
866 ++count; | 866 ++count; |
867 } | 867 } |
868 } | 868 } |
OLD | NEW |