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

Unified Diff: lib/src/codegen/js_codegen.dart

Issue 1082333004: fixes #145, optional params+initializing formals+private fields (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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 | « no previous file | test/codegen/expect/temps.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_codegen.dart
diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
index afbeb695f176f000612fd3b1258acf8bf09396d4..1a218daabc442e012ac6716277692100fa2a7234 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -885,23 +885,25 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
var body = [];
for (var param in parameters.parameters) {
- // TODO(justinfagnani): rename identifier if necessary
- var name = param.identifier.name;
+ var jsParam = _visit(param.identifier);
if (param.kind == ParameterKind.NAMED) {
+ // Parameters will be passed using their real names, not the (possibly
+ // renamed) local variable.
+ var paramName = js.string(param.identifier.name, "'");
body.add(js.statement('let # = # && # in # ? #.# : #;', [
- name,
+ jsParam,
_namedArgTemp,
- js.string(name, "'"),
+ paramName,
_namedArgTemp,
_namedArgTemp,
- name,
+ paramName,
_defaultParamValue(param),
]));
} else if (param.kind == ParameterKind.POSITIONAL) {
body.add(js.statement('if (# === void 0) # = #;', [
- name,
- name,
+ jsParam,
+ jsParam,
_defaultParamValue(param)
]));
}
« no previous file with comments | « no previous file | test/codegen/expect/temps.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698