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

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

Issue 1484263002: Use destructuring assignments for named parameters (#180) (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/js/printer.dart ('k') | test/codegen/expect/closure.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/js/template.dart
diff --git a/lib/src/js/template.dart b/lib/src/js/template.dart
index 85a62516ca2874c903ff8b2b16a4d3915af73480..88e7321bae747d335bf9840dc36746b66c37e9cd 100644
--- a/lib/src/js/template.dart
+++ b/lib/src/js/template.dart
@@ -230,8 +230,8 @@ class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> {
return (arguments) {
var value = arguments[nameOrPosition];
- Identifier toIdentifier(item) {
- if (item is Identifier) return item;
+ Parameter toIdentifier(item) {
+ if (item is Parameter) return item;
if (item is String) return new Identifier(item);
return error('Interpolated value #$nameOrPosition is not an Identifier'
' or List of Identifiers: $value');
@@ -826,6 +826,37 @@ class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> {
Instantiator visitExportClause(ExportClause node) =>
throw new UnimplementedError();
+
+ @override
+ Instantiator visitDestructuredVariable(DestructuredVariable node) {
+ Instantiator makeName = visit(node.name);
+ Instantiator makeStructure = visit(node.structure);
+ Instantiator makeDefaultValue = visit(node.defaultValue);
+ return (arguments) {
+ return new DestructuredVariable(
+ name: makeName(arguments),
+ structure: makeStructure(arguments),
+ defaultValue: makeDefaultValue(arguments));
+ };
+ }
+
+ @override
+ Instantiator visitArrayBindingPattern(ArrayBindingPattern node) {
+ List<Instantiator> makeVars = node.variables.map(this.visit).toList();
+ return (arguments) {
+ return new ArrayBindingPattern(
+ makeVars.map((m) => m(arguments)).toList());
+ };
+ }
+
+ @override
+ Instantiator visitObjectBindingPattern(ObjectBindingPattern node) {
+ List<Instantiator> makeVars = node.variables.map(this.visit).toList();
+ return (arguments) {
+ return new ObjectBindingPattern(
+ makeVars.map((m) => m(arguments)).toList());
+ };
+ }
}
/**
« no previous file with comments | « lib/src/js/printer.dart ('k') | test/codegen/expect/closure.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698