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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 Instantiator instantiator; | 49 Instantiator instantiator; |
50 | 50 |
51 int positionalArgumentCount = -1; | 51 int positionalArgumentCount = -1; |
52 | 52 |
53 // Null, unless there are named holes. | 53 // Null, unless there are named holes. |
54 List<String> holeNames; | 54 List<String> holeNames; |
55 bool get isPositional => holeNames == null; | 55 bool get isPositional => holeNames == null; |
56 | 56 |
57 Template(this.source, this.ast, | 57 Template(this.source, this.ast, |
58 {this.isExpression: true, this.forceCopy: false}) { | 58 {this.isExpression: true, this.forceCopy: false}) { |
| 59 assert(this.isExpression ? ast is Expression : ast is Statement); |
59 _compile(); | 60 _compile(); |
60 } | 61 } |
61 | 62 |
62 Template.withExpressionResult(this.ast) | 63 Template.withExpressionResult(this.ast) |
63 : source = null, isExpression = true, forceCopy = false { | 64 : source = null, isExpression = true, forceCopy = false { |
64 assert(ast is Expression); | 65 assert(ast is Expression); |
65 assert(_checkNoPlaceholders()); | 66 assert(_checkNoPlaceholders()); |
66 positionalArgumentCount = 0; | 67 positionalArgumentCount = 0; |
67 instantiator = (arguments) => ast; | 68 instantiator = (arguments) => ast; |
68 } | 69 } |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 if (count != before) containsInterpolatedNode.add(node); | 746 if (count != before) containsInterpolatedNode.add(node); |
746 return null; | 747 return null; |
747 } | 748 } |
748 | 749 |
749 visitInterpolatedNode(InterpolatedNode node) { | 750 visitInterpolatedNode(InterpolatedNode node) { |
750 containsInterpolatedNode.add(node); | 751 containsInterpolatedNode.add(node); |
751 if (node.isNamed) holeNames.add(node.nameOrPosition); | 752 if (node.isNamed) holeNames.add(node.nameOrPosition); |
752 ++count; | 753 ++count; |
753 } | 754 } |
754 } | 755 } |
OLD | NEW |