* Weird case: if JDT determines that this local class is totally
* uninstantiable, it won't bother allocating a local name.
*/
return program.getLiteralNull();
}
JClassType newType = (JClassType) typeMap.get(typeBinding);
MethodBinding b = x.binding;
JMethod ctor = (JMethod) typeMap.get(b);
JMethodCall call;
JClassType javaLangString = program.getTypeJavaLangString();
if (newType == javaLangString) {
/*
* MAGIC: java.lang.String is implemented as a JavaScript String
* primitive with a modified prototype. This requires funky handling of
* constructor calls. We find a method named _String() whose signature
* matches the requested constructor
*/
int ctorArgc = ctor.params.size();
JMethod targetMethod = null;
outer : for (int j = 0; j < javaLangString.methods.size(); ++j) {
JMethod method = (JMethod) javaLangString.methods.get(j);
if (method.getName().equals("_String")
&& method.params.size() == ctorArgc) {
for (int i = 0; i < ctorArgc; ++i) {
JParameter mparam = (JParameter) method.params.get(i);
JParameter cparam = (JParameter) ctor.params.get(i);
if (mparam.getType() != cparam.getType()) {
continue outer;
}
}
targetMethod = method;
break;
}
}
if (targetMethod == null) {
throw new InternalCompilerException(
"String constructor error; no matching implementation.");
}
call = new JMethodCall(program, makeSourceInfo(x), null, targetMethod);
} else {
JNewInstance newInstance = new JNewInstance(program, info, newType);
call = new JMethodCall(program, info, newInstance, ctor);
}
// Plain old regular user arguments
if (x.arguments != null) {
for (int i = 0, n = x.arguments.length; i < n; ++i) {
call.getArgs().add(dispProcessExpression(x.arguments[i]));
}
}
// Synthetic args for inner classes
ReferenceBinding targetBinding = b.declaringClass;
if (targetBinding.isNestedType() && !targetBinding.isStatic()) {
NestedTypeBinding nestedBinding = (NestedTypeBinding) targetBinding;
// Synthetic this args for inner classes
if (nestedBinding.enclosingInstances != null) {
for (int i = 0; i < nestedBinding.enclosingInstances.length; ++i) {
SyntheticArgumentBinding arg = nestedBinding.enclosingInstances[i];
JClassType syntheticThisType = (JClassType) typeMap.get(arg.type);
call.getArgs().add(createThisRef(info, syntheticThisType));
}
}
// Synthetic locals for local classes
if (nestedBinding.outerLocalVariables != null) {