Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: lib/src/js/template.dart

Issue 1530563003: Generate all runtime files from dart. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Reverted to new .dart files in input_sdk: please compare them against previous patchset Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 96
97 /// Instantiates the template with the given [arguments]. 97 /// Instantiates the template with the given [arguments].
98 /// 98 ///
99 /// This method fills in the holes with the given arguments. The [arguments] 99 /// This method fills in the holes with the given arguments. The [arguments]
100 /// must be either a [List] or a [Map]. 100 /// must be either a [List] or a [Map].
101 Node instantiate(var arguments) { 101 Node instantiate(var arguments) {
102 if (arguments is List) { 102 if (arguments is List) {
103 if (arguments.length != positionalArgumentCount) { 103 if (arguments.length != positionalArgumentCount) {
104 throw 'Wrong number of template arguments, given ${arguments.length}, ' 104 throw 'Wrong number of template arguments, given ${arguments.length}, '
105 'expected $positionalArgumentCount'; 105 'expected $positionalArgumentCount:\n$source';
106 } 106 }
107 return instantiator(arguments); 107 return instantiator(arguments);
108 } 108 }
109 assert(arguments is Map); 109 assert(arguments is Map);
110 if (holeNames.length < arguments.length) { 110 if (holeNames.length < arguments.length) {
111 // This search is in O(n), but we only do it in case of an error, and the 111 // This search is in O(n), but we only do it in case of an error, and the
112 // number of holes should be quite limited. 112 // number of holes should be quite limited.
113 String unusedNames = 113 String unusedNames =
114 arguments.keys.where((name) => !holeNames.contains(name)).join(", "); 114 arguments.keys.where((name) => !holeNames.contains(name)).join(", ");
115 throw "Template arguments has unused mappings: $unusedNames"; 115 throw "Template arguments has unused mappings: $unusedNames";
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 if (count != before) containsInterpolatedNode.add(node); 883 if (count != before) containsInterpolatedNode.add(node);
884 return null; 884 return null;
885 } 885 }
886 886
887 visitInterpolatedNode(InterpolatedNode node) { 887 visitInterpolatedNode(InterpolatedNode node) {
888 containsInterpolatedNode.add(node); 888 containsInterpolatedNode.add(node);
889 if (node.isNamed) holeNames.add(node.nameOrPosition); 889 if (node.isNamed) holeNames.add(node.nameOrPosition);
890 ++count; 890 ++count;
891 } 891 }
892 } 892 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698