Revision: 10038
Author: [email protected]
Date: Wed Apr 20 08:47:17 2011
Log: Some Java AST cleanups.
http://gwt-code-reviews.appspot.com/1422805/
Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=10038
Modified:
/trunk/dev/core/src/com/google/gwt/dev/jjs/ast/HasType.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JAbsentArrayDimension.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JNameOf.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JNonNullType.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/CloneExpressionVisitor.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/ImplementClassLiteralsAsFields.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/TypeRemapper.java
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/ast/HasType.java Thu Apr 5
13:07:16 2007
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/ast/HasType.java Wed Apr 20
08:47:17 2011
@@ -19,5 +19,8 @@
* Interface implemented by Java entities that have a type associated with
them.
*/
public interface HasType {
+ /**
+ * Returns the type of this expression.
+ */
JType getType();
}
=======================================
---
/trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JAbsentArrayDimension.java
Tue Apr 19 10:10:18 2011
+++
/trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JAbsentArrayDimension.java
Wed Apr 20 08:47:17 2011
@@ -26,10 +26,7 @@
public static final JExpression INSTANCE = new
JAbsentArrayDimension(SourceOrigin.UNKNOWN);
- /**
- * These are only supposed to be constructed by JProgram.
- */
- JAbsentArrayDimension(SourceInfo sourceInfo) {
+ private JAbsentArrayDimension(SourceInfo sourceInfo) {
super(sourceInfo);
}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JNameOf.java Fri Apr 2
14:35:01 2010
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JNameOf.java Wed Apr 20
08:47:17 2011
@@ -23,12 +23,13 @@
public class JNameOf extends JExpression {
private final HasName node;
- private final JNonNullType stringType;
-
- public JNameOf(SourceInfo info, JNonNullType stringType, HasName node) {
+ private final JClassType stringType;
+
+ public JNameOf(SourceInfo info, JClassType stringType, HasName node) {
super(info);
this.node = node;
this.stringType = stringType;
+ assert stringType.getName().equals("java.lang.String");
}
public HasName getNode() {
@@ -36,7 +37,7 @@
}
public JNonNullType getType() {
- return stringType;
+ return stringType.getNonNull();
}
@Override
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java Tue Apr
19 10:10:18 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java Wed Apr
20 08:47:17 2011
@@ -44,14 +44,14 @@
classLiterals.add(classLit);
cur = ((JArrayType) cur).getElementType();
}
- return new JNewArray(info, arrayType.getNonNull(), dims, null,
classLiterals);
+ return new JNewArray(info, arrayType, dims, null, classLiterals);
}
public static JNewArray createInitializers(SourceInfo info, JArrayType
arrayType,
List<JExpression> initializers) {
List<JClassLiteral> classLiterals = new ArrayList<JClassLiteral>();
classLiterals.add(new JClassLiteral(info.makeChild(), arrayType));
- return new JNewArray(info, arrayType.getNonNull(), null, initializers,
classLiterals);
+ return new JNewArray(info, arrayType, null, initializers,
classLiterals);
}
public final List<JExpression> dims;
@@ -63,12 +63,12 @@
*/
private final List<JClassLiteral> classLiterals;
- private JNonNullType type;
-
- public JNewArray(SourceInfo info, JNonNullType type, List<JExpression>
dims,
+ private JArrayType type;
+
+ public JNewArray(SourceInfo info, JArrayType type, List<JExpression>
dims,
List<JExpression> initializers, List<JClassLiteral> classLits) {
super(info);
- setType(type);
+ this.type = type;
this.dims = dims;
this.initializers = initializers;
this.classLiterals = classLits;
@@ -97,7 +97,7 @@
}
public JNonNullType getType() {
- return type;
+ return type.getNonNull();
}
@Override
@@ -120,8 +120,7 @@
return false;
}
- public void setType(JNonNullType type) {
- assert type.getUnderlyingType() instanceof JArrayType;
+ public void setType(JArrayType type) {
this.type = type;
}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JNonNullType.java Sat
Jan 22 17:19:44 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JNonNullType.java Wed
Apr 20 08:47:17 2011
@@ -52,6 +52,11 @@
public boolean isAbstract() {
return ref.isAbstract();
}
+
+ @Override
+ public boolean isExternal() {
+ return ref.isExternal();
+ }
public boolean isFinal() {
return ref.isFinal();
=======================================
---
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/CloneExpressionVisitor.java
Tue Apr 19 10:10:18 2011
+++
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/CloneExpressionVisitor.java
Wed Apr 20 08:47:17 2011
@@ -25,6 +25,7 @@
import com.google.gwt.dev.jjs.ast.JCastOperation;
import com.google.gwt.dev.jjs.ast.JCharLiteral;
import com.google.gwt.dev.jjs.ast.JClassLiteral;
+import com.google.gwt.dev.jjs.ast.JClassType;
import com.google.gwt.dev.jjs.ast.JConditional;
import com.google.gwt.dev.jjs.ast.JDoubleLiteral;
import com.google.gwt.dev.jjs.ast.JExpression;
@@ -232,14 +233,15 @@
@Override
public boolean visit(JNameOf x, Context ctx) {
- expression = new JNameOf(x.getSourceInfo(), x.getType(), x.getNode());
+ expression =
+ new JNameOf(x.getSourceInfo(), (JClassType)
x.getType().getUnderlyingType(), x.getNode());
return false;
}
@Override
public boolean visit(JNewArray x, Context ctx) {
expression =
- new JNewArray(x.getSourceInfo(), x.getType(),
cloneExpressions(x.dims),
+ new JNewArray(x.getSourceInfo(), x.getArrayType(),
cloneExpressions(x.dims),
cloneExpressions(x.initializers), x.getClassLiterals());
return false;
}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java
Tue Apr 19 10:10:18 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/EnumOrdinalizer.java
Wed Apr 20 08:47:17 2011
@@ -33,6 +33,7 @@
import com.google.gwt.dev.jjs.ast.JMethodCall;
import com.google.gwt.dev.jjs.ast.JModVisitor;
import com.google.gwt.dev.jjs.ast.JNode;
+import com.google.gwt.dev.jjs.ast.JNonNullType;
import com.google.gwt.dev.jjs.ast.JPrimitiveType;
import com.google.gwt.dev.jjs.ast.JProgram;
import com.google.gwt.dev.jjs.ast.JReferenceType;
@@ -770,13 +771,14 @@
return JPrimitiveType.INT;
}
- JType uType = getPossiblyUnderlyingType(type);
+ boolean nonNull = type instanceof JNonNullType;
+ JType uType = nonNull ? ((JNonNullType) type).getUnderlyingType() :
type;
if (uType instanceof JArrayType) {
JArrayType aType = (JArrayType) uType;
JType leafType = aType.getLeafType();
if (canBeOrdinal(leafType)) {
JArrayType newAType = program.getTypeArray(JPrimitiveType.INT,
aType.getDims());
- return newAType.getNonNull();
+ return nonNull ? newAType.getNonNull() : newAType;
}
}
=======================================
---
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/ImplementClassLiteralsAsFields.java
Tue Apr 19 10:10:18 2011
+++
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/ImplementClassLiteralsAsFields.java
Wed Apr 20 08:47:17 2011
@@ -171,11 +171,11 @@
if (type instanceof JArrayType) {
// There's only one seed function for all arrays
JDeclaredType arrayType = program.getIndexedType("Array");
- call.addArg(new JNameOf(info, className.getType(), arrayType));
+ call.addArg(new JNameOf(info, program.getTypeJavaLangString(),
arrayType));
} else if (type instanceof JClassType) {
// Add the name of the seed function for concrete types
- call.addArg(new JNameOf(info, className.getType(), type));
+ call.addArg(new JNameOf(info, program.getTypeJavaLangString(),
type));
} else if (type instanceof JPrimitiveType) {
// And give primitive types an illegal, though meaningful, value
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java Tue
Apr 19 10:10:18 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java Wed
Apr 20 08:47:17 2011
@@ -138,7 +138,7 @@
// Not found, must be null
ctx.replaceMe(JNullLiteral.INSTANCE);
} else {
- ctx.replaceMe(new JNameOf(x.getSourceInfo(),
stringLiteral.getType(), named));
+ ctx.replaceMe(new JNameOf(x.getSourceInfo(),
program.getTypeJavaLangString(), named));
}
}
}
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/TypeRemapper.java Tue
Apr 19 10:10:18 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/TypeRemapper.java Wed
Apr 20 08:47:17 2011
@@ -16,6 +16,7 @@
package com.google.gwt.dev.jjs.impl;
import com.google.gwt.dev.jjs.ast.Context;
+import com.google.gwt.dev.jjs.ast.JArrayType;
import com.google.gwt.dev.jjs.ast.JBinaryOperation;
import com.google.gwt.dev.jjs.ast.JCastOperation;
import com.google.gwt.dev.jjs.ast.JConditional;
@@ -24,7 +25,6 @@
import com.google.gwt.dev.jjs.ast.JMethod;
import com.google.gwt.dev.jjs.ast.JModVisitor;
import com.google.gwt.dev.jjs.ast.JNewArray;
-import com.google.gwt.dev.jjs.ast.JNonNullType;
import com.google.gwt.dev.jjs.ast.JType;
import com.google.gwt.dev.jjs.ast.JVariable;
@@ -75,7 +75,7 @@
@Override
public void endVisit(JNewArray x, Context ctx) {
- x.setType((JNonNullType) remap(x.getType()));
+ x.setType((JArrayType) remap(x.getArrayType()));
}
@Override
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors