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

Unified Diff: compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java

Issue 8301002: Namespace named parameters to avoid conflicts (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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 | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
===================================================================
--- compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java (revision 418)
+++ compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java (working copy)
@@ -1188,7 +1188,8 @@
continue;
}
- JsExpression paramName = string(jsParam.getName().getShortIdent());
+ String paramNameStr = getPropNameForNamedParameter(jsParam);
+ JsExpression paramName = string(getPropNameForNamedParameter(jsParam));
if (generateClosureCompatibleCode) {
paramName = AstUtil.call(null,
AstUtil.nameref(null, "JSCompiler_renameProperty"), paramName);
@@ -1197,7 +1198,7 @@
JsExpression ppSeen = AstUtil.preinc(null, seen.makeRef());
JsBinaryOperation thenExpr = AstUtil.comma(null, ppSeen,
- AstUtil.newNameRef(namedParam.getName().makeRef(), jsParam.getName()));
+ AstUtil.newNameRef(namedParam.getName().makeRef(), paramNameStr));
DartExpression defaultValue = param.getDefaultExpr();
JsExpression elseExpr = (defaultValue != null)
@@ -1250,6 +1251,18 @@
return tramp;
}
+ private String mangleNamedParameterName(String name) {
+ return "$p_" + name;
+ }
+
+ private String getPropNameForNamedParameter(JsParameter jsParam) {
+ return mangleNamedParameterName(jsParam.getName().getShortIdent());
+ }
+
+ private String getPropNameForNameParameter(DartNamedExpression namedExpr) {
jgw 2011/10/17 19:12:07 Name[d]Parameter?
John Lenz 2011/10/17 19:19:39 Done.
+ return mangleNamedParameterName(namedExpr.getName().getTargetName());
+ }
+
/**
* If necessary, add object holding aliases for any parameters
* captured by function closures.
@@ -2711,9 +2724,9 @@
for (DartExpression arg : args) {
if (arg instanceof DartNamedExpression) {
DartNamedExpression namedExpr = ((DartNamedExpression) arg);
- String targetName = namedExpr.getName().getTargetName();
+ JsExpression targetName = string(getPropNameForNameParameter(namedExpr));
JsPropertyInitializer propInit = new JsPropertyInitializer(
- string(targetName),
+ targetName,
(JsExpression) generate(namedExpr.getExpression()));
bag.getPropertyInitializers().add(propInit);
}
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698