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

Unified Diff: pkg/compiler/lib/src/js/template.dart

Issue 932053002: Support for interpolated declarations in the js parser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review Created 5 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/js/rewrite_async.dart ('k') | tests/compiler/dart2js/js_parser_statements_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js/template.dart
diff --git a/pkg/compiler/lib/src/js/template.dart b/pkg/compiler/lib/src/js/template.dart
index 7740431fc05ed717483c4adbbc7e189beac6657e..eb4089ad807090f3b6270d5192658c0e6933e8ad 100644
--- a/pkg/compiler/lib/src/js/template.dart
+++ b/pkg/compiler/lib/src/js/template.dart
@@ -185,6 +185,11 @@ class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> {
return new VariableUse(value);
}
+ static Expression convertStringToVariableDeclaration(String value) {
+ assert(identiferRE.hasMatch(value));
+ return new VariableDeclaration(value);
+ }
+
Instantiator visitInterpolatedExpression(InterpolatedExpression node) {
var nameOrPosition = node.nameOrPosition;
return (arguments) {
@@ -195,6 +200,16 @@ class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> {
};
}
+ Instantiator visitInterpolatedDeclaration(InterpolatedDeclaration node) {
+ var nameOrPosition = node.nameOrPosition;
+ return (arguments) {
+ var value = arguments[nameOrPosition];
+ if (value is Declaration) return value;
+ if (value is String) return convertStringToVariableDeclaration(value);
+ error('Interpolated value #$nameOrPosition is not a declaration: $value');
+ };
+ }
+
Instantiator visitSplayableExpression(Node node) {
if (node is InterpolatedExpression) {
var nameOrPosition = node.nameOrPosition;
« no previous file with comments | « pkg/compiler/lib/src/js/rewrite_async.dart ('k') | tests/compiler/dart2js/js_parser_statements_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698