| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 Instantiator visitSplayable(Node node) { | 174 Instantiator visitSplayable(Node node) { |
| 175 // TODO(sra): Process immediate [InterpolatedNode]s, permitting splaying. | 175 // TODO(sra): Process immediate [InterpolatedNode]s, permitting splaying. |
| 176 return visit(node); | 176 return visit(node); |
| 177 } | 177 } |
| 178 | 178 |
| 179 Instantiator visitNode(Node node) { | 179 Instantiator visitNode(Node node) { |
| 180 throw 'Unimplemented InstantiatorGeneratorVisitor for $node'; | 180 throw 'Unimplemented InstantiatorGeneratorVisitor for $node'; |
| 181 } | 181 } |
| 182 | 182 |
| 183 static RegExp identiferRE = new RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$'); | 183 static RegExp identifierRE = new RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$'); |
| 184 | 184 |
| 185 static Expression convertStringToVariableUse(String value) { | 185 static Expression convertStringToVariableUse(String value) { |
| 186 assert(identiferRE.hasMatch(value)); | 186 assert(identifierRE.hasMatch(value)); |
| 187 return new VariableUse(value); | 187 return new VariableUse(value); |
| 188 } | 188 } |
| 189 | 189 |
| 190 static Expression convertStringToVariableDeclaration(String value) { | 190 static Expression convertStringToVariableDeclaration(String value) { |
| 191 assert(identiferRE.hasMatch(value)); | 191 assert(identifierRE.hasMatch(value)); |
| 192 return new VariableDeclaration(value); | 192 return new VariableDeclaration(value); |
| 193 } | 193 } |
| 194 | 194 |
| 195 Instantiator visitInterpolatedExpression(InterpolatedExpression node) { | 195 Instantiator visitInterpolatedExpression(InterpolatedExpression node) { |
| 196 var nameOrPosition = node.nameOrPosition; | 196 var nameOrPosition = node.nameOrPosition; |
| 197 return (arguments) { | 197 return (arguments) { |
| 198 var value = arguments[nameOrPosition]; | 198 var value = arguments[nameOrPosition]; |
| 199 if (value is Expression) return value; | 199 if (value is Expression) return value; |
| 200 if (value is String) return convertStringToVariableUse(value); | 200 if (value is String) return convertStringToVariableUse(value); |
| 201 error('Interpolated value #$nameOrPosition is not an Expression: $value'); | 201 error('Interpolated value #$nameOrPosition is not an Expression: $value'); |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 node.visitChildren(this); | 763 node.visitChildren(this); |
| 764 if (count != before) containsInterpolatedNode.add(node); | 764 if (count != before) containsInterpolatedNode.add(node); |
| 765 } | 765 } |
| 766 | 766 |
| 767 visitInterpolatedNode(InterpolatedNode node) { | 767 visitInterpolatedNode(InterpolatedNode node) { |
| 768 containsInterpolatedNode.add(node); | 768 containsInterpolatedNode.add(node); |
| 769 if (node.isNamed) holeNames.add(node.nameOrPosition); | 769 if (node.isNamed) holeNames.add(node.nameOrPosition); |
| 770 ++count; | 770 ++count; |
| 771 } | 771 } |
| 772 } | 772 } |
| OLD | NEW |