Cleaned up some JProgram create* methods. Moved dotify from JProgram to BuildTypeMap.
http://gwt-code-reviews.appspot.com/304801/show
Patch by: tobyr
Review by: me
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@7867 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java b/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
index 1025e52..6ba5944 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
@@ -323,13 +323,12 @@
case OBFUSCATED:
obfuscateMap = JsStringInterner.exec(jprogram, jsProgram);
JsObfuscateNamer.exec(jsProgram);
- if (JsStackEmulator.getStackMode(propertyOracles) ==
- JsStackEmulator.StackMode.STRIP) {
+ if (JsStackEmulator.getStackMode(propertyOracles) == JsStackEmulator.StackMode.STRIP) {
boolean changed = false;
for (int i = 0; i < jsProgram.getFragmentCount(); i++) {
JsBlock fragment = jsProgram.getFragmentBlock(i);
changed = JsDuplicateFunctionRemover.exec(jsProgram, fragment)
- || changed;
+ || changed;
}
if (changed) {
JsUnusedFunctionRemover.exec(jsProgram);
@@ -347,7 +346,7 @@
default:
throw new InternalCompilerException("Unknown output mode");
}
-
+
// (10.8) Handle cross-island references.
// No new JsNames or references to JSNames can be introduced after this
// point.
@@ -677,7 +676,7 @@
if (isAggressivelyOptimize) {
// inlining
didChange = MethodInliner.exec(jprogram) || didChange;
-
+
// remove same parameters value
didChange = SameParameterValueOptimizer.exec(jprogram) || didChange;
}
@@ -805,9 +804,9 @@
throws UnableToCompleteException {
SourceInfo sourceInfo = program.createSourceInfoSynthetic(
JavaToJavaScriptCompiler.class, "Bootstrap method");
- JMethod bootStrapMethod = program.createMethod(sourceInfo,
- "init".toCharArray(), program.getIndexedType("EntryMethodHolder"),
- program.getTypeVoid(), false, true, true, false, false);
+ JMethod bootStrapMethod = program.createMethod(sourceInfo, "init",
+ program.getIndexedType("EntryMethodHolder"), program.getTypeVoid(),
+ false, true, true, false, false);
bootStrapMethod.freezeParamTypes();
bootStrapMethod.setSynthetic();
@@ -817,7 +816,7 @@
// Also remember $entry, which we'll handle specially in GenerateJsAst
JMethod registerEntry = program.getIndexedMethod("Impl.registerEntry");
program.addEntryMethod(registerEntry);
-
+
for (String mainClassName : mainClassNames) {
block.addStmt(makeStatsCalls(program, mainClassName));
JDeclaredType mainType = program.getFromTypeMap(mainClassName);
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
index 9914d57..05feb9d 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
@@ -131,6 +131,39 @@
}
}
+ /**
+ * Helper to create an assignment, used to initalize fields, etc.
+ */
+ public static JExpressionStatement createAssignmentStmt(SourceInfo info,
+ JExpression lhs, JExpression rhs) {
+ JBinaryOperation assign = new JBinaryOperation(info, lhs.getType(),
+ JBinaryOperator.ASG, lhs, rhs);
+ return assign.makeStatement();
+ }
+
+ public static JLocal createLocal(SourceInfo info, String name, JType type,
+ boolean isFinal, JMethodBody enclosingMethodBody) {
+ assert (name != null);
+ assert (type != null);
+ assert (enclosingMethodBody != null);
+ JLocal x = new JLocal(info, name, type, isFinal, enclosingMethodBody);
+ enclosingMethodBody.addLocal(x);
+ return x;
+ }
+
+ public static JParameter createParameter(SourceInfo info, String name,
+ JType type, boolean isFinal, boolean isThis, JMethod enclosingMethod) {
+ assert (name != null);
+ assert (type != null);
+ assert (enclosingMethod != null);
+
+ JParameter x = new JParameter(info, name, type, isFinal, isThis,
+ enclosingMethod);
+
+ enclosingMethod.addParam(x);
+ return x;
+ }
+
public static String getJsniSig(JMethod method) {
return getJsniSig(method, true);
}
@@ -185,18 +218,6 @@
return latest;
}
- private static String dotify(char[][] name) {
- StringBuffer result = new StringBuffer();
- for (int i = 0; i < name.length; ++i) {
- if (i > 0) {
- result.append('.');
- }
-
- result.append(name[i]);
- }
- return result.toString();
- }
-
/**
* The main logic behind {@link #lastFragmentLoadingBefore(int, int...)} and
* {@link #lastFragmentLoadingBefore(List, int, int, int...)}.
@@ -393,46 +414,30 @@
optimizationsStarted = true;
}
- /**
- * Helper to create an assignment, used to initalize fields, etc.
- */
- public JExpressionStatement createAssignmentStmt(SourceInfo info,
- JExpression lhs, JExpression rhs) {
- JBinaryOperation assign = new JBinaryOperation(info, lhs.getType(),
- JBinaryOperator.ASG, lhs, rhs);
- return assign.makeStatement();
- }
-
- public JClassType createClass(SourceInfo info, char[][] name,
+ public JClassType createClass(SourceInfo info, String name,
boolean isAbstract, boolean isFinal) {
- String sname = dotify(name);
- return createClass(info, sname, isAbstract, isFinal);
- }
-
- public JClassType createClass(SourceInfo info, String sname,
- boolean isAbstract, boolean isFinal) {
- JClassType x = new JClassType(info, sname, isAbstract, isFinal);
+ JClassType x = new JClassType(info, name, isAbstract, isFinal);
allTypes.add(x);
- putIntoTypeMap(sname, x);
+ putIntoTypeMap(name, x);
- if (CODEGEN_TYPES_SET.contains(sname)) {
+ if (CODEGEN_TYPES_SET.contains(name)) {
codeGenTypes.add(x);
}
- if (INDEX_TYPES_SET.contains(sname)) {
+ if (INDEX_TYPES_SET.contains(name)) {
indexedTypes.put(x.getShortName(), x);
- if (sname.equals("java.lang.Object")) {
+ if (name.equals("java.lang.Object")) {
typeJavaLangObject = x;
- } else if (sname.equals("java.lang.String")) {
+ } else if (name.equals("java.lang.String")) {
typeString = x;
typeNonNullString = getNonNullType(x);
- } else if (sname.equals("java.lang.Enum")) {
+ } else if (name.equals("java.lang.Enum")) {
typeJavaLangEnum = x;
- } else if (sname.equals("java.lang.Class")) {
+ } else if (name.equals("java.lang.Class")) {
typeClass = x;
- } else if (sname.equals("com.google.gwt.core.client.JavaScriptObject")) {
+ } else if (name.equals("com.google.gwt.core.client.JavaScriptObject")) {
typeSpecialJavaScriptObject = x;
- } else if (sname.equals("com.google.gwt.lang.ClassLiteralHolder")) {
+ } else if (name.equals("com.google.gwt.lang.ClassLiteralHolder")) {
typeSpecialClassLiteralHolder = x;
}
}
@@ -454,75 +459,70 @@
return x;
}
- public JEnumType createEnum(SourceInfo info, char[][] name) {
- String sname = dotify(name);
- JEnumType x = new JEnumType(info, sname);
+ public JEnumType createEnum(SourceInfo info, String name) {
+ JEnumType x = new JEnumType(info, name);
x.setSuperClass(getTypeJavaLangEnum());
allTypes.add(x);
- putIntoTypeMap(sname, x);
+ putIntoTypeMap(name, x);
return x;
}
- public JField createEnumField(SourceInfo info, char[] name,
+ public JField createEnumField(SourceInfo info, String name,
JEnumType enclosingType, JClassType type, int ordinal) {
assert (name != null);
assert (type != null);
assert (ordinal >= 0);
- String sname = String.valueOf(name);
- JEnumField x = new JEnumField(info, sname, ordinal, enclosingType, type);
+ JEnumField x = new JEnumField(info, name, ordinal, enclosingType, type);
enclosingType.addField(x);
return x;
}
- public JExternalType createExternalType(SourceInfo info, char[][] name) {
+ public JExternalType createExternalType(SourceInfo info, String name) {
JExternalType x;
- String sname = dotify(name);
- x = externalTypes.get(sname);
+ x = externalTypes.get(name);
if (x != null) {
return x;
}
- x = new JExternalType(info, sname);
- if (INDEX_TYPES_SET.contains(sname)) {
+ x = new JExternalType(info, name);
+ if (INDEX_TYPES_SET.contains(name)) {
indexedTypes.put(x.getShortName(), x);
}
return x;
}
- public JField createField(SourceInfo info, char[] name,
+ public JField createField(SourceInfo info, String name,
JDeclaredType enclosingType, JType type, boolean isStatic,
Disposition disposition) {
assert (name != null);
assert (enclosingType != null);
assert (type != null);
- String sname = String.valueOf(name);
- JField x = new JField(info, sname, enclosingType, type, isStatic,
+ JField x = new JField(info, name, enclosingType, type, isStatic,
disposition);
if (indexedTypes.containsValue(enclosingType)) {
- indexedFields.put(enclosingType.getShortName() + '.' + sname, x);
+ indexedFields.put(enclosingType.getShortName() + '.' + name, x);
}
enclosingType.addField(x);
return x;
}
- public JInterfaceType createInterface(SourceInfo info, char[][] name) {
- String sname = dotify(name);
- JInterfaceType x = new JInterfaceType(info, sname);
+ public JInterfaceType createInterface(SourceInfo info, String name) {
+ JInterfaceType x = new JInterfaceType(info, name);
allTypes.add(x);
- putIntoTypeMap(sname, x);
+ putIntoTypeMap(name, x);
- if (INDEX_TYPES_SET.contains(sname)) {
+ if (INDEX_TYPES_SET.contains(name)) {
indexedTypes.put(x.getShortName(), x);
- if (sname.equals("java.lang.Cloneable")) {
+ if (name.equals("java.lang.Cloneable")) {
typeJavaLangCloneable = x;
- } else if (sname.equals("java.io.Serializable")) {
+ } else if (name.equals("java.io.Serializable")) {
typeJavaIoSerializable = x;
}
}
@@ -530,26 +530,6 @@
return x;
}
- public JLocal createLocal(SourceInfo info, char[] name, JType type,
- boolean isFinal, JMethodBody enclosingMethodBody) {
- assert (name != null);
- assert (type != null);
- assert (enclosingMethodBody != null);
-
- JLocal x = new JLocal(info, String.valueOf(name), type, isFinal,
- enclosingMethodBody);
-
- enclosingMethodBody.addLocal(x);
- return x;
- }
-
- public JMethod createMethod(SourceInfo info, char[] name,
- JDeclaredType enclosingType, JType returnType, boolean isAbstract,
- boolean isStatic, boolean isFinal, boolean isPrivate, boolean isNative) {
- return createMethod(info, String.valueOf(name), enclosingType, returnType,
- isAbstract, isStatic, isFinal, isPrivate, isNative);
- }
-
public JMethod createMethod(SourceInfo info, String name,
JDeclaredType enclosingType, JType returnType, boolean isAbstract,
boolean isStatic, boolean isFinal, boolean isPrivate, boolean isNative) {
@@ -573,19 +553,6 @@
return x;
}
- public JParameter createParameter(SourceInfo info, char[] name, JType type,
- boolean isFinal, boolean isThis, JMethod enclosingMethod) {
- assert (name != null);
- assert (type != null);
- assert (enclosingMethod != null);
-
- JParameter x = new JParameter(info, String.valueOf(name), type, isFinal,
- isThis, enclosingMethod);
-
- enclosingMethod.addParam(x);
- return x;
- }
-
/**
* Create a SourceInfo object when the source is derived from a physical
* location.
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/BuildTypeMap.java b/dev/core/src/com/google/gwt/dev/jjs/impl/BuildTypeMap.java
index 232bc13..0c4d0f4 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/BuildTypeMap.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/BuildTypeMap.java
@@ -144,8 +144,9 @@
SourceInfo info = makeSourceInfo(argument, enclosingBody.getMethod());
LocalVariableBinding b = argument.binding;
JType localType = (JType) typeMap.get(b.type);
- JLocal newLocal = program.createLocal(info, argument.name, localType,
- b.isFinal(), enclosingBody);
+ JLocal newLocal = JProgram.createLocal(info,
+ String.valueOf(argument.name), localType, b.isFinal(),
+ enclosingBody);
typeMap.put(b, newLocal);
return true;
} catch (Throwable e) {
@@ -170,9 +171,9 @@
// Enums have hidden arguments for name and value
if (enclosingType.isEnumOrSubclass() != null) {
- program.createParameter(info, "enum$name".toCharArray(),
+ JProgram.createParameter(info, "enum$name",
program.getTypeJavaLangString(), true, false, newCtor);
- program.createParameter(info, "enum$ordinal".toCharArray(),
+ JProgram.createParameter(info, "enum$ordinal",
program.getTypePrimitiveInt(), true, false, newCtor);
}
@@ -262,8 +263,9 @@
JMethodBody enclosingBody = findEnclosingMethod(scope);
SourceInfo info = makeSourceInfo(localDeclaration,
enclosingBody.getMethod());
- JLocal newLocal = program.createLocal(info, localDeclaration.name,
- localType, b.isFinal(), enclosingBody);
+ JLocal newLocal = JProgram.createLocal(info,
+ String.valueOf(localDeclaration.name), localType, b.isFinal(),
+ enclosingBody);
typeMap.put(b, newLocal);
return true;
} catch (Throwable e) {
@@ -307,8 +309,7 @@
return process(typeDeclaration);
}
- private void addThrownExceptions(MethodBinding methodBinding,
- JMethod method) {
+ private void addThrownExceptions(MethodBinding methodBinding, JMethod method) {
for (ReferenceBinding thrownBinding : methodBinding.thrownExceptions) {
JClassType type = (JClassType) typeMap.get(thrownBinding.erasure());
method.addThrownException(type);
@@ -318,8 +319,9 @@
private JField createEnumField(SourceInfo info, FieldBinding binding,
JReferenceType enclosingType) {
JType type = (JType) typeMap.get(binding.type);
- JField field = program.createEnumField(info, binding.name,
- (JEnumType) enclosingType, (JClassType) type, binding.original().id);
+ JField field = program.createEnumField(info,
+ String.valueOf(binding.name), (JEnumType) enclosingType,
+ (JClassType) type, binding.original().id);
info.addCorrelation(program.getCorrelator().by(field));
typeMap.put(binding, field);
return field;
@@ -346,8 +348,8 @@
disposition = Disposition.NONE;
}
- JField field = program.createField(info, binding.name, enclosingType,
- type, binding.isStatic(), disposition);
+ JField field = program.createField(info, String.valueOf(binding.name),
+ enclosingType, type, binding.isStatic(), disposition);
typeMap.put(binding, field);
info.addCorrelation(program.getCorrelator().by(field));
return field;
@@ -358,8 +360,8 @@
JType type = (JType) typeMap.get(binding.type);
SourceInfo info = enclosingType.getSourceInfo().makeChild(
BuildDeclMapVisitor.class, "Field " + String.valueOf(binding.name));
- JField field = program.createField(info, binding.name, enclosingType,
- type, false, Disposition.FINAL);
+ JField field = program.createField(info, String.valueOf(binding.name),
+ enclosingType, type, false, Disposition.FINAL);
info.addCorrelation(program.getCorrelator().by(field));
if (binding.matchingField != null) {
typeMap.put(binding.matchingField, field);
@@ -372,8 +374,9 @@
JMethod enclosingMethod) {
JType type = (JType) typeMap.get(binding.type);
SourceInfo info = makeSourceInfo(binding.declaration, enclosingMethod);
- JParameter param = program.createParameter(info, binding.name, type,
- binding.isFinal(), false, enclosingMethod);
+ JParameter param = JProgram.createParameter(info,
+ String.valueOf(binding.name), type, binding.isFinal(), false,
+ enclosingMethod);
typeMap.put(binding, param);
return param;
}
@@ -381,10 +384,10 @@
private JParameter createParameter(SyntheticArgumentBinding arg,
String argName, JMethod enclosingMethod) {
JType type = (JType) typeMap.get(arg.type);
- JParameter param = program.createParameter(
+ JParameter param = JProgram.createParameter(
enclosingMethod.getSourceInfo().makeChild(BuildTypeMap.class,
- "Parameter " + argName), argName.toCharArray(), type, true,
- false, enclosingMethod);
+ "Parameter " + argName), argName, type, true, false,
+ enclosingMethod);
return param;
}
@@ -405,9 +408,8 @@
// Define the method
JMethod synthetic = program.createMethod(type.getSourceInfo().makeChild(
- BuildDeclMapVisitor.class, "Synthetic constructor"),
- "new".toCharArray(), type, program.getNonNullType(type), false, true,
- true, false, false);
+ BuildDeclMapVisitor.class, "Synthetic constructor"), "new", type,
+ program.getNonNullType(type), false, true, true, false, false);
synthetic.setSynthetic();
synthetic.addThrownExceptions(constructor.getThrownExceptions());
@@ -424,10 +426,10 @@
*/
JParameter enclosingInstance = null;
if (!staticClass) {
- enclosingInstance = program.createParameter(
+ enclosingInstance = JProgram.createParameter(
synthetic.getSourceInfo().makeChild(BuildDeclMapVisitor.class,
- "outer instance"), "this$outer".toCharArray(), enclosingType,
- false, false, synthetic);
+ "outer instance"), "this$outer", enclosingType, false, false,
+ synthetic);
}
/*
@@ -445,11 +447,10 @@
synthetic.getSourceInfo().makeChild(BuildDeclMapVisitor.class,
"enclosing instance"), enclosingInstance));
} else {
- JParameter syntheticParam = program.createParameter(
+ JParameter syntheticParam = JProgram.createParameter(
synthetic.getSourceInfo().makeChild(BuildDeclMapVisitor.class,
- "Argument " + param.getName()),
- param.getName().toCharArray(), param.getType(), true, false,
- synthetic);
+ "Argument " + param.getName()), param.getName(),
+ param.getType(), true, false, synthetic);
newInstance.addArg(new JParameterRef(
syntheticParam.getSourceInfo().makeChild(
BuildDeclMapVisitor.class, "reference"), syntheticParam));
@@ -567,7 +568,7 @@
&& type != program.getIndexedType("Array")) {
JMethod getClassMethod = program.createMethod(
type.getSourceInfo().makeChild(BuildDeclMapVisitor.class,
- "Synthetic getClass()"), "getClass".toCharArray(), type,
+ "Synthetic getClass()"), "getClass", type,
program.getTypeJavaLangClass(), false, false, false, false, false);
assert (type.getMethods().get(2) == getClassMethod);
getClassMethod.freezeParamTypes();
@@ -640,10 +641,9 @@
} else if (parameters.length == 1) {
assert newMethod.getName().equals("valueOf");
assert typeMap.get(parameters[0]) == program.getTypeJavaLangString();
- program.createParameter(newMethod.getSourceInfo().makeChild(
- BuildDeclMapVisitor.class, "name parameter"),
- "name".toCharArray(), program.getTypeJavaLangString(), true,
- false, newMethod);
+ JProgram.createParameter(newMethod.getSourceInfo().makeChild(
+ BuildDeclMapVisitor.class, "name parameter"), "name",
+ program.getTypeJavaLangString(), true, false, newMethod);
} else {
assert false;
}
@@ -655,8 +655,9 @@
private JMethod processMethodBinding(MethodBinding b,
JDeclaredType enclosingType, SourceInfo info) {
JType returnType = (JType) typeMap.get(b.returnType);
- JMethod newMethod = program.createMethod(info, b.selector, enclosingType,
- returnType, b.isAbstract(), b.isStatic(), b.isFinal(), b.isPrivate(),
+ JMethod newMethod = program.createMethod(info,
+ String.valueOf(b.selector), enclosingType, returnType,
+ b.isAbstract(), b.isStatic(), b.isFinal(), b.isPrivate(),
b.isNative());
addThrownExceptions(b, newMethod);
if (b.isSynthetic()) {
@@ -767,7 +768,7 @@
private boolean process(TypeDeclaration typeDeclaration) {
try {
- char[][] name = typeDeclaration.binding.compoundName;
+ String name = dotify(typeDeclaration.binding.compoundName);
SourceTypeBinding binding = typeDeclaration.binding;
if (binding instanceof LocalTypeBinding) {
char[] localName = binding.constantPoolName();
@@ -779,13 +780,7 @@
return false;
}
- for (int i = 0, c = localName.length; i < c; ++i) {
- if (localName[i] == '/') {
- localName[i] = '.';
- }
- }
- name = new char[1][0];
- name[0] = localName;
+ name = new String(localName).replace('/', '.');
}
SourceInfo info = makeSourceInfo(typeDeclaration);
@@ -815,17 +810,15 @@
* exists) is always in slot 1.
*/
JMethod clinit = program.createMethod(info.makeChild(
- BuildTypeMapVisitor.class, "Class initializer"),
- "$clinit".toCharArray(), newType, program.getTypeVoid(), false,
- true, true, true, false);
+ BuildTypeMapVisitor.class, "Class initializer"), "$clinit",
+ newType, program.getTypeVoid(), false, true, true, true, false);
clinit.freezeParamTypes();
clinit.setSynthetic();
if (newType instanceof JClassType) {
JMethod init = program.createMethod(info.makeChild(
- BuildTypeMapVisitor.class, "Instance initializer"),
- "$init".toCharArray(), newType, program.getTypeVoid(), false,
- false, true, true, false);
+ BuildTypeMapVisitor.class, "Instance initializer"), "$init",
+ newType, program.getTypeVoid(), false, false, true, true, false);
init.freezeParamTypes();
init.setSynthetic();
}
@@ -886,6 +879,18 @@
return createPeersForNonTypeDecls(unitDecls, typeMap, jsProgram);
}
+ static String dotify(char[][] name) {
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < name.length; ++i) {
+ if (i > 0) {
+ result.append('.');
+ }
+
+ result.append(name[i]);
+ }
+ return result.toString();
+ }
+
private static TypeDeclaration[] createPeersForNonTypeDecls(
CompilationUnitDeclaration[] unitDecls, TypeMap typeMap,
JsProgram jsProgram) {
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/CatchBlockNormalizer.java b/dev/core/src/com/google/gwt/dev/jjs/impl/CatchBlockNormalizer.java
index d32ef57..8aa8ec0 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/CatchBlockNormalizer.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/CatchBlockNormalizer.java
@@ -71,7 +71,7 @@
JMethod caughtMethod = program.getIndexedMethod("Exceptions.caught");
JMethodCall call = new JMethodCall(catchInfo, null, caughtMethod);
call.addArg(new JLocalRef(catchInfo, exVar));
- newCatchBlock.addStmt(program.createAssignmentStmt(catchInfo,
+ newCatchBlock.addStmt(JProgram.createAssignmentStmt(catchInfo,
new JLocalRef(catchInfo, exVar), call));
}
@@ -153,9 +153,8 @@
private void pushTempLocal(SourceInfo sourceInfo) {
if (localIndex == tempLocals.size()) {
- JLocal newTemp = program.createLocal(sourceInfo,
- ("$e" + localIndex).toCharArray(), program.getTypeJavaLangObject(),
- false, currentMethodBody);
+ JLocal newTemp = JProgram.createLocal(sourceInfo, "$e" + localIndex,
+ program.getTypeJavaLangObject(), false, currentMethodBody);
tempLocals.add(newTemp);
}
++localIndex;
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/CompoundAssignmentNormalizer.java b/dev/core/src/com/google/gwt/dev/jjs/impl/CompoundAssignmentNormalizer.java
index bb4b516..2b31c8f 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/CompoundAssignmentNormalizer.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/CompoundAssignmentNormalizer.java
@@ -440,8 +440,7 @@
if (temp == null) {
temp = program.createLocal(currentMethodBody.getSourceInfo(),
- (getTempPrefix() + localCounter++).toCharArray(), type, false,
- currentMethodBody);
+ getTempPrefix() + localCounter++, type, false, currentMethodBody);
}
tracker.useLocal(temp);
return temp;
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
index 77de903..564b9ed 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaAST.java
@@ -680,7 +680,7 @@
JParameter param = paramIt.next();
if (arg.matchingField != null) {
JField field = (JField) typeMap.get(arg);
- block.addStmt(program.createAssignmentStmt(info,
+ block.addStmt(JProgram.createAssignmentStmt(info,
createVariableRef(info, field), createVariableRef(info,
param)));
}
@@ -692,7 +692,7 @@
SyntheticArgumentBinding arg = nestedBinding.outerLocalVariables[i];
JParameter param = paramIt.next();
JField field = (JField) typeMap.get(arg);
- block.addStmt(program.createAssignmentStmt(info,
+ block.addStmt(JProgram.createAssignmentStmt(info,
createVariableRef(info, field), createVariableRef(info,
param)));
}
@@ -1573,19 +1573,22 @@
if (x.collection.resolvedType.isArrayType()) {
/**
* <pre>
- * for (T[] i$array = collection, int i$index = 0, int i$max = i$array.length;
- * i$index < i$max; ++i$index) {
+ * for (final T[] i$array = collection,
+ * int i$index = 0,
+ * final int i$max = i$array.length;
+ * i$index < i$max; ++i$index) {
* T elementVar = i$array[i$index];
* // user action
* }
* </pre>
*/
- JLocal arrayVar = createSyntheticLocal(info, elementVarName + "$array",
- (JType) typeMap.get(x.collection.resolvedType));
- JLocal indexVar = createSyntheticLocal(info, elementVarName + "$index",
- program.getTypePrimitiveInt());
- JLocal maxVar = createSyntheticLocal(info, elementVarName + "$max",
- program.getTypePrimitiveInt());
+ JLocal arrayVar = JProgram.createLocal(info, elementVarName + "$array",
+ ((JType) typeMap.get(x.collection.resolvedType)), true,
+ currentMethodBody);
+ JLocal indexVar = JProgram.createLocal(info, elementVarName + "$index",
+ program.getTypePrimitiveInt(), false, currentMethodBody);
+ JLocal maxVar = JProgram.createLocal(info, elementVarName + "$max",
+ program.getTypePrimitiveInt(), true, currentMethodBody);
List<JStatement> initializers = new ArrayList<JStatement>(3);
// T[] i$array = arr
@@ -1626,8 +1629,9 @@
* }
* </pre>
*/
- JLocal iteratorVar = createSyntheticLocal(info, elementVarName
- + "$iterator", program.getIndexedType("Iterator"));
+ JLocal iteratorVar = JProgram.createLocal(info,
+ (elementVarName + "$iterator"), program.getIndexedType("Iterator"),
+ false, currentMethodBody);
List<JStatement> initializers = new ArrayList<JStatement>(1);
// Iterator<T> i$iterator = collection.iterator()
@@ -2012,7 +2016,7 @@
}
}
- /**
+ /**
* Create a bridge method. It calls a same-named method with the same
* arguments, but with a different type signature.
*
@@ -2026,7 +2030,7 @@
GenerateJavaAST.class, "bridge method");
// create the method itself
JMethod bridgeMethod = program.createMethod(info,
- jdtBridgeMethod.selector, clazz,
+ String.valueOf(jdtBridgeMethod.selector), clazz,
(JType) typeMap.get(jdtBridgeMethod.returnType.erasure()), false,
false, true, false, false);
bridgeMethod.setSynthetic();
@@ -2098,13 +2102,12 @@
JFieldRef value = new JFieldRef(sourceInfo, null, field, type);
map.propInits.add(new JsonObject.JsonPropInit(sourceInfo, key, value));
}
- JField mapField = program.createField(sourceInfo,
- "enum$map".toCharArray(), type, map.getType(), true,
- Disposition.FINAL);
+ JField mapField = program.createField(sourceInfo, "enum$map", type,
+ map.getType(), true, Disposition.FINAL);
// Initialize in clinit.
JMethodBody clinitBody = (JMethodBody) type.getMethods().get(0).getBody();
- JExpressionStatement assignment = program.createAssignmentStmt(
+ JExpressionStatement assignment = JProgram.createAssignmentStmt(
sourceInfo, createVariableRef(sourceInfo, mapField), map);
clinitBody.getBlock().addStmt(assignment);
return mapField;
@@ -2124,11 +2127,6 @@
return createThisRef(targetType, list);
}
- private JLocal createSyntheticLocal(SourceInfo info, String name, JType type) {
- return program.createLocal(info, name.toCharArray(), type, false,
- currentMethodBody);
- }
-
/**
* Helper to create an expression of the target type, possibly by accessing
* synthetic this fields on the passed-in expression. This is needed by a
@@ -2483,7 +2481,7 @@
if (type == null) {
// Indicates a binary-only class literal
type = program.createExternalType(info,
- ((ReferenceBinding) value).compoundName);
+ BuildTypeMap.dotify(((ReferenceBinding) value).compoundName));
}
return Lists.<JAnnotationArgument> create(program.getLiteralClass(type));
@@ -2508,7 +2506,7 @@
toReturn = new JAnnotation(info, type);
} else {
JExternalType external = program.createExternalType(info,
- annotationType.compoundName);
+ BuildTypeMap.dotify(annotationType.compoundName));
toReturn = new JAnnotation(info, external);
}
@@ -2575,7 +2573,7 @@
} else {
// Indicates a binary-only annotation type
JExternalType externalType = program.createExternalType(
- x.getSourceInfo(), binding.compoundName);
+ x.getSourceInfo(), BuildTypeMap.dotify(binding.compoundName));
annotation = new JAnnotation(x.getSourceInfo(), externalType);
}
processAnnotationProperties(x.getSourceInfo(), annotation,
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/JavaScriptObjectNormalizer.java b/dev/core/src/com/google/gwt/dev/jjs/impl/JavaScriptObjectNormalizer.java
index 1eb02f0..1e48ed9 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/JavaScriptObjectNormalizer.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/JavaScriptObjectNormalizer.java
@@ -232,10 +232,9 @@
SourceInfo info = instance.getSourceInfo().makeChild(
JavaScriptObjectNormalizer.class,
"Temporary assignment for instance with side-effects");
- JLocal local = program.createLocal(info,
- "maybeJsoInvocation".toCharArray(), instance.getType(), true,
- currentMethodBody.peek());
- multi.exprs.add(program.createAssignmentStmt(info,
+ JLocal local = JProgram.createLocal(info, "maybeJsoInvocation",
+ instance.getType(), true, currentMethodBody.peek());
+ multi.exprs.add(JProgram.createAssignmentStmt(info,
new JLocalRef(info, local), instance).getExpr());
instance = new JLocalRef(info, local);
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/JsoDevirtualizer.java b/dev/core/src/com/google/gwt/dev/jjs/impl/JsoDevirtualizer.java
index 4649e55..a9da281 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/JsoDevirtualizer.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/JsoDevirtualizer.java
@@ -131,16 +131,15 @@
// Create the new method.
String name = objectMethod.getName() + "__devirtual$";
JMethod newMethod = program.createMethod(sourceInfo.makeChild(
- JsoDevirtualizer.class, "Devirtualized method"), name.toCharArray(),
- jsoType, objectMethod.getType(), false, true, true, false, false);
+ JsoDevirtualizer.class, "Devirtualized method"), name, jsoType,
+ objectMethod.getType(), false, true, true, false, false);
newMethod.setSynthetic();
// Setup parameters.
- JParameter thisParam = program.createParameter(sourceInfo,
- "this$static".toCharArray(), program.getTypeJavaLangObject(), true,
- true, newMethod);
+ JParameter thisParam = JProgram.createParameter(sourceInfo, "this$static",
+ program.getTypeJavaLangObject(), true, true, newMethod);
for (JParameter oldParam : objectMethod.getParams()) {
- program.createParameter(sourceInfo, oldParam.getName().toCharArray(),
+ JProgram.createParameter(sourceInfo, oldParam.getName(),
oldParam.getType(), true, false, newMethod);
}
newMethod.freezeParamTypes();
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/ResolveRebinds.java b/dev/core/src/com/google/gwt/dev/jjs/impl/ResolveRebinds.java
index 373c2bd..8a93585 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/ResolveRebinds.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/ResolveRebinds.java
@@ -218,7 +218,7 @@
// c_g_g_d_c_i_DOMImpl
toReturn = program.createMethod(info, requestType.getName().replace("_",
- "_1").replace('.', '_').toCharArray(), holderType,
+ "_1").replace('.', '_'), holderType,
program.getNonNullType(program.getTypeJavaLangObject()), false, true,
true, false, false);
toReturn.freezeParamTypes();
diff --git a/dev/core/test/com/google/gwt/dev/jjs/JjsTypeTest.java b/dev/core/test/com/google/gwt/dev/jjs/JjsTypeTest.java
index 4bb4cb9..2640cfe 100644
--- a/dev/core/test/com/google/gwt/dev/jjs/JjsTypeTest.java
+++ b/dev/core/test/com/google/gwt/dev/jjs/JjsTypeTest.java
@@ -141,7 +141,7 @@
assertTrue(typeOracle.canTriviallyCast(classJso, classJso1));
assertTrue(typeOracle.canTriviallyCast(classJso, classJso1));
-
+
assertTrue(typeOracle.canTriviallyCast(arrayOfA, intfSerializable));
assertFalse(typeOracle.canTriviallyCast(intfSerializable, arrayOfA));
@@ -215,15 +215,14 @@
private JClassType createClass(String className, JClassType superClass,
boolean isAbstract, boolean isFinal) {
- JClassType clazz = program.createClass(synthSource, CharOperation.splitOn(
- '.', className.toCharArray()), isAbstract, isFinal);
+ JClassType clazz = program.createClass(synthSource, className, isAbstract,
+ isFinal);
clazz.setSuperClass(superClass);
return clazz;
}
private JInterfaceType createInterface(String className) {
- JInterfaceType intf = program.createInterface(synthSource,
- CharOperation.splitOn('.', className.toCharArray()));
+ JInterfaceType intf = program.createInterface(synthSource, className);
return intf;
}