Revision: 7637
Author: sco...@google.com
Date: Mon Mar 1 10:24:16 2010
Log: JsNew's constructor target expression should be immutable.
http://gwt-code-reviews.appspot.com/154806/show
Review by: cromwellian
http://code.google.com/p/google-web-toolkit/source/detail?r=7637
Modified:
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
/trunk/dev/core/src/com/google/gwt/dev/js/JsHoister.java
/trunk/dev/core/src/com/google/gwt/dev/js/JsParser.java
/trunk/dev/core/src/com/google/gwt/dev/js/ast/JsNew.java
=======================================
---
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
Mon Mar 1 09:03:44 2010
+++
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
Mon Mar 1 10:24:16 2010
@@ -1102,9 +1102,8 @@
@Override
public void endVisit(JNewInstance x, Context ctx) {
- JsNew newOp = new JsNew(x.getSourceInfo());
JsNameRef nameRef =
names.get(x.getClassType()).makeRef(x.getSourceInfo());
- newOp.setConstructorExpression(nameRef);
+ JsNew newOp = new JsNew(x.getSourceInfo(), nameRef);
push(newOp);
}
@@ -1600,10 +1599,9 @@
lhs.setQualifier(seedFuncName.makeRef(sourceInfo));
JsExpression rhs;
if (x.getSuperClass() != null) {
- JsNew newExpr = new JsNew(sourceInfo);
JsNameRef superPrototypeRef =
names.get(x.getSuperClass()).makeRef(
sourceInfo);
- newExpr.setConstructorExpression(superPrototypeRef);
+ JsNew newExpr = new JsNew(sourceInfo, superPrototypeRef);
rhs = newExpr;
} else {
rhs = new JsObjectLiteral(sourceInfo);
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/js/JsHoister.java Mon Oct 26
14:02:26 2009
+++ /trunk/dev/core/src/com/google/gwt/dev/js/JsHoister.java Mon Mar 1
10:24:16 2010
@@ -39,6 +39,7 @@
import com.google.gwt.dev.js.ast.JsThisRef;
import com.google.gwt.dev.js.ast.JsVisitor;
+import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
@@ -151,14 +152,13 @@
@Override
public void endVisit(JsNew x, JsContext<JsExpression> ctx) {
- JsNew toReturn = new JsNew(x.getSourceInfo());
-
- List<JsExpression> arguments = toReturn.getArguments();
int size = x.getArguments().size();
+ List<JsExpression> arguments = new ArrayList<JsExpression>(size);
while (size-- > 0) {
arguments.add(0, stack.pop());
}
- toReturn.setConstructorExpression(stack.pop());
+ JsNew toReturn = new JsNew(x.getSourceInfo(), stack.pop());
+ toReturn.getArguments().addAll(arguments);
stack.push(toReturn);
}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/js/JsParser.java Thu Aug 13
12:43:26 2009
+++ /trunk/dev/core/src/com/google/gwt/dev/js/JsParser.java Mon Mar 1
10:24:16 2010
@@ -807,14 +807,12 @@
}
private JsNew mapNew(Node newNode) throws JsParserException {
-
- JsNew newExpr = new JsNew(makeSourceInfo(newNode));
-
// Map the constructor expression, which is often just the name of
// some lambda.
//
Node fromCtorExpr = newNode.getFirstChild();
- newExpr.setConstructorExpression(mapExpression(fromCtorExpr));
+ JsNew newExpr = new JsNew(makeSourceInfo(newNode),
+ mapExpression(fromCtorExpr));
// Iterate over and map the arguments.
//
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/js/ast/JsNew.java Fri Sep 26
08:20:00 2008
+++ /trunk/dev/core/src/com/google/gwt/dev/js/ast/JsNew.java Mon Mar 1
10:24:16 2010
@@ -29,8 +29,9 @@
private JsExpression ctorExpr;
- public JsNew(SourceInfo sourceInfo) {
+ public JsNew(SourceInfo sourceInfo, JsExpression ctorExpr) {
super(sourceInfo);
+ this.ctorExpr = ctorExpr;
}
public List<JsExpression> getArguments() {
@@ -57,10 +58,6 @@
public boolean isDefinitelyNull() {
return false;
}
-
- public void setConstructorExpression(JsExpression ctorExpr) {
- this.ctorExpr = ctorExpr;
- }
public void traverse(JsVisitor v, JsContext<JsExpression> ctx) {
if (v.visit(this, ctx)) {
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors