// original params are now frozen
info.addCorrelation(program.getCorrelator().by(newMethod));
int syntheticParamCount = 0;
ReferenceBinding declaringClass = b.declaringClass;
if (declaringClass.isNestedType() && !declaringClass.isStatic()) {
// add synthetic args for outer this and locals
NestedTypeBinding nestedBinding = (NestedTypeBinding) declaringClass;
Set<String> alreadyNamedVariables = new HashSet<String>();
if (nestedBinding.enclosingInstances != null) {
for (int i = 0; i < nestedBinding.enclosingInstances.length; ++i) {
SyntheticArgumentBinding arg = nestedBinding.enclosingInstances[i];
String argName = String.valueOf(arg.name);
if (alreadyNamedVariables.contains(argName)) {
argName += "_" + i;
}
createParameter(arg, argName, newMethod);
++syntheticParamCount;
alreadyNamedVariables.add(argName);
}
}
if (nestedBinding.outerLocalVariables != null) {
for (int i = 0; i < nestedBinding.outerLocalVariables.length; ++i) {
SyntheticArgumentBinding arg = nestedBinding.outerLocalVariables[i];
String argName = String.valueOf(arg.name);
if (alreadyNamedVariables.contains(argName)) {
argName += "_" + i;
}
createParameter(arg, argName, newMethod);
++syntheticParamCount;
alreadyNamedVariables.add(argName);
}
}
}
typeMap.put(b, newMethod);
// Now let's implicitly create a static function called 'new' that will
// allow construction from JSNI methods
if (!enclosingType.isAbstract()) {
ReferenceBinding enclosingBinding = ctorDecl.binding.declaringClass.enclosingType();
JReferenceType outerType = enclosingBinding == null ? null
: (JReferenceType) typeMap.get(enclosingBinding);
createSyntheticConstructor(newMethod,
ctorDecl.binding.declaringClass.isStatic(), outerType);
}