Revision: 10179
Author: [email protected]
Date: Thu May 12 10:09:08 2011
Log: Misc gwtc cleanups.
http://gwt-code-reviews.appspot.com/1446802/
Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=10179
Modified:
/trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java
/trunk/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java
=======================================
---
/trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java
Mon Aug 30 04:31:11 2010
+++
/trunk/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java
Thu May 12 10:09:08 2011
@@ -137,7 +137,7 @@
@Override
public String toString() {
- return methodSig != null ? methodSig : className;
+ return isClass() ? className : getJsniIdent();
}
private void readObject(ObjectInputStream in) throws IOException,
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java Wed Apr
20 08:47:17 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java Thu May
12 10:09:08 2011
@@ -16,8 +16,8 @@
package com.google.gwt.dev.jjs.ast;
import com.google.gwt.dev.jjs.SourceInfo;
-
-import java.util.ArrayList;
+import com.google.gwt.dev.util.collect.Lists;
+
import java.util.List;
/**
@@ -26,8 +26,6 @@
public class JNewArray extends JExpression {
public static JNewArray createDims(SourceInfo info, JArrayType
arrayType, List<JExpression> dims) {
- List<JClassLiteral> classLiterals = new ArrayList<JClassLiteral>();
-
// Produce all class literals that will eventually get generated.
int realDims = 0;
for (JExpression dim : dims) {
@@ -37,11 +35,12 @@
++realDims;
}
+ List<JClassLiteral> classLiterals = Lists.create();
JType cur = arrayType;
for (int i = 0; i < realDims; ++i) {
// Walk down each type from most dims to least.
JClassLiteral classLit = new JClassLiteral(info.makeChild(), cur);
- classLiterals.add(classLit);
+ classLiterals = Lists.add(classLiterals, classLit);
cur = ((JArrayType) cur).getElementType();
}
return new JNewArray(info, arrayType, dims, null, classLiterals);
@@ -49,8 +48,8 @@
public static JNewArray createInitializers(SourceInfo info, JArrayType
arrayType,
List<JExpression> initializers) {
- List<JClassLiteral> classLiterals = new ArrayList<JClassLiteral>();
- classLiterals.add(new JClassLiteral(info.makeChild(), arrayType));
+ List<JClassLiteral> classLiterals =
+ Lists.create(new JClassLiteral(info.makeChild(), arrayType));
return new JNewArray(info, arrayType, null, initializers,
classLiterals);
}
@@ -75,7 +74,7 @@
}
public JArrayType getArrayType() {
- return (JArrayType) type.getUnderlyingType();
+ return type;
}
/**
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java Tue
May 10 05:59:20 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java Thu
May 12 10:09:08 2011
@@ -653,7 +653,7 @@
*/
if (!hasExplicitThis) {
ReferenceBinding declaringClass = (ReferenceBinding)
x.binding.declaringClass.erasure();
- if (declaringClass instanceof NestedTypeBinding) {
+ if (isNested(declaringClass)) {
NestedTypeBinding nestedBinding = (NestedTypeBinding)
declaringClass;
if (nestedBinding.enclosingInstances != null) {
for (SyntheticArgumentBinding arg :
nestedBinding.enclosingInstances) {
@@ -768,7 +768,7 @@
if (x.isSuperAccess()) {
JExpression qualifier = pop(x.qualification);
ReferenceBinding superClass = x.binding.declaringClass;
- boolean nestedSuper = superClass.isNestedType()
&& !superClass.isStatic();
+ boolean nestedSuper = isNested(superClass);
if (nestedSuper) {
processSuperCallThisArgs(superClass, call, qualifier,
x.qualification);
}
@@ -779,7 +779,7 @@
} else {
assert (x.qualification == null);
ReferenceBinding declaringClass = x.binding.declaringClass;
- boolean nested = declaringClass.isNestedType()
&& !declaringClass.isStatic();
+ boolean nested = isNested(declaringClass);
if (nested) {
processThisCallThisArgs(declaringClass, call);
}
@@ -1553,7 +1553,8 @@
// Map synthetic arguments for outer this.
ReferenceBinding declaringClass = (ReferenceBinding)
x.binding.declaringClass.erasure();
- if (declaringClass.isNestedType() && !declaringClass.isStatic()) {
+ boolean isNested = isNested(declaringClass);
+ if (isNested) {
NestedTypeBinding nestedBinding = (NestedTypeBinding)
declaringClass;
if (nestedBinding.enclosingInstances != null) {
for (int i = 0; i < nestedBinding.enclosingInstances.length;
++i) {
@@ -1571,7 +1572,7 @@
}
// Map synthetic arguments for locals.
- if (declaringClass.isNestedType() && !declaringClass.isStatic()) {
+ if (isNested) {
// add synthetic args for locals
NestedTypeBinding nestedBinding = (NestedTypeBinding)
declaringClass;
// add synthetic args for outer this and locals
@@ -1886,7 +1887,7 @@
*/
int index = 0;
SourceTypeBinding binding = x.binding;
- if (binding.isNestedType() && !binding.isStatic()) {
+ if (isNested(binding)) {
// add synthetic fields for outer this and locals
assert (type instanceof JClassType);
NestedTypeBinding nestedBinding = (NestedTypeBinding) binding;
@@ -2487,24 +2488,20 @@
// Synthetic args for inner classes
ReferenceBinding targetBinding = (ReferenceBinding)
b.declaringClass.erasure();
- NestedTypeBinding nestedBinding = null;
- if (targetBinding.isNestedType() && !targetBinding.isStatic()) {
- nestedBinding = (NestedTypeBinding) targetBinding;
- }
- if (nestedBinding != null) {
+ boolean isNested = isNested(targetBinding);
+ if (isNested) {
// Synthetic this args for inner classes
- if (nestedBinding.enclosingInstances != null) {
+ if (targetBinding.syntheticEnclosingInstanceTypes() != null) {
ReferenceBinding checkedTargetType =
targetBinding.isAnonymousType() ? (ReferenceBinding)
targetBinding.superclass()
.erasure() : targetBinding;
ReferenceBinding targetEnclosingType =
checkedTargetType.enclosingType();
- for (SyntheticArgumentBinding arg :
nestedBinding.enclosingInstances) {
- TypeBinding argType = arg.type.erasure();
+ for (ReferenceBinding argType :
targetBinding.syntheticEnclosingInstanceTypes()) {
+ argType = (ReferenceBinding) argType.erasure();
if (qualifier != null && argType == targetEnclosingType) {
call.addArg(qualExpr);
} else {
- JExpression thisRef =
- makeThisReference(info, (ReferenceBinding) argType,
false, scope);
+ JExpression thisRef = makeThisReference(info, argType,
false, scope);
call.addArg(thisRef);
}
}
@@ -2515,10 +2512,10 @@
call.addArgs(arguments);
// Synthetic args for inner classes
- if (nestedBinding != null) {
+ if (isNested) {
// Synthetic locals for local classes
- if (nestedBinding.outerLocalVariables != null) {
- for (SyntheticArgumentBinding arg :
nestedBinding.outerLocalVariables) {
+ if (targetBinding.syntheticOuterLocalVariables() != null) {
+ for (SyntheticArgumentBinding arg :
targetBinding.syntheticOuterLocalVariables()) {
LocalVariableBinding targetVariable =
arg.actualOuterLocalVariable;
VariableBinding[] path =
scope.getEmulationPath(targetVariable);
assert path.length == 1;
@@ -2812,6 +2809,10 @@
static String intern(String s) {
return stringInterner.intern(s);
}
+
+ static boolean isNested(ReferenceBinding binding) {
+ return binding.isNestedType() && !binding.isStatic();
+ }
/**
* Returns <code>true</code> if JDT optimized the condition to
@@ -3065,6 +3066,7 @@
JDeclaredType enclosingType = (JDeclaredType)
typeMap.get(declaringClass);
assert !enclosingType.isExternal();
JMethod method;
+ boolean isNested = isNested(declaringClass);
if (x.isConstructor()) {
method = new JConstructor(info, (JClassType) enclosingType);
if (x.binding.declaringClass.isEnum()) {
@@ -3075,7 +3077,7 @@
method));
}
// add synthetic args for outer this
- if (declaringClass.isNestedType() && !declaringClass.isStatic()) {
+ if (isNested) {
NestedTypeBinding nestedBinding = (NestedTypeBinding)
declaringClass;
if (nestedBinding.enclosingInstances != null) {
for (int i = 0; i < nestedBinding.enclosingInstances.length;
++i) {
@@ -3099,7 +3101,7 @@
createParameters(method, x);
if (x.isConstructor()) {
- if (declaringClass.isNestedType() && !declaringClass.isStatic()) {
+ if (isNested) {
// add synthetic args for locals
NestedTypeBinding nestedBinding = (NestedTypeBinding)
declaringClass;
// add synthetic args for outer this and locals
=======================================
--- /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java Wed
Apr 20 08:47:17 2011
+++ /trunk/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java Thu
May 12 10:09:08 2011
@@ -100,45 +100,35 @@
JStringLiteral stringLiteral = (JStringLiteral) arg0;
String stringValue = stringLiteral.getValue();
- HasName named = null;
+ JNode node = null;
JDeclaredType refType;
JsniRef ref = JsniRef.parse(stringValue);
if (ref != null) {
final List<String> errors = new ArrayList<String>();
- JNode node =
- JsniRefLookup.findJsniRefTarget(ref, program, new
JsniRefLookup.ErrorReporter() {
- public void reportError(String error) {
- errors.add(error);
- }
- });
-
+ node = JsniRefLookup.findJsniRefTarget(ref, program, new
JsniRefLookup.ErrorReporter() {
+ public void reportError(String error) {
+ errors.add(error);
+ }
+ });
if (!errors.isEmpty()) {
for (String error : errors) {
logger.log(TreeLogger.ERROR, error);
}
}
-
- if (node instanceof HasName) {
- named = (HasName) node;
- }
-
} else {
// See if it's just @foo.Bar, which would result in the class seed
- refType =
+ node =
program.getFromTypeMap(stringValue.charAt(0) == '@' ?
stringValue.substring(1)
: stringValue);
- if (refType != null) {
- named = refType;
- }
- }
-
- if (named == null) {
+ }
+ if (node == null) {
// Not found, must be null
ctx.replaceMe(JNullLiteral.INSTANCE);
} else {
- ctx.replaceMe(new JNameOf(x.getSourceInfo(),
program.getTypeJavaLangString(), named));
+ ctx.replaceMe(new JNameOf(x.getSourceInfo(),
program.getTypeJavaLangString(),
+ (HasName) node));
}
}
}
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors