|
|
@ -36,7 +36,6 @@ import java.util.List; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
public class NewExprent extends Exprent { |
|
|
|
public class NewExprent extends Exprent { |
|
|
|
|
|
|
|
|
|
|
|
private InvocationExprent constructor; |
|
|
|
private InvocationExprent constructor; |
|
|
|
private final VarType newType; |
|
|
|
private final VarType newType; |
|
|
|
private List<Exprent> lstDims = new ArrayList<Exprent>(); |
|
|
|
private List<Exprent> lstDims = new ArrayList<Exprent>(); |
|
|
@ -80,12 +79,7 @@ public class NewExprent extends Exprent { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public VarType getExprType() { |
|
|
|
public VarType getExprType() { |
|
|
|
if (anonymous) { |
|
|
|
return anonymous ? DecompilerContext.getClassProcessor().getMapRootClasses().get(newType.value).anonymousClassType : newType; |
|
|
|
return DecompilerContext.getClassProcessor().getMapRootClasses().get(newType.value).anonymousClassType; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
return newType; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -163,24 +157,22 @@ public class NewExprent extends Exprent { |
|
|
|
TextBuffer buf = new TextBuffer(); |
|
|
|
TextBuffer buf = new TextBuffer(); |
|
|
|
|
|
|
|
|
|
|
|
if (anonymous) { |
|
|
|
if (anonymous) { |
|
|
|
|
|
|
|
|
|
|
|
ClassNode child = DecompilerContext.getClassProcessor().getMapRootClasses().get(newType.value); |
|
|
|
ClassNode child = DecompilerContext.getClassProcessor().getMapRootClasses().get(newType.value); |
|
|
|
|
|
|
|
|
|
|
|
buf.append("("); |
|
|
|
buf.append("("); |
|
|
|
|
|
|
|
|
|
|
|
if (!lambda && constructor != null) { |
|
|
|
if (!lambda && constructor != null) { |
|
|
|
|
|
|
|
InvocationExprent invSuper = child.superInvocation; |
|
|
|
|
|
|
|
|
|
|
|
InvocationExprent invsuper = child.superInvocation; |
|
|
|
ClassNode newNode = DecompilerContext.getClassProcessor().getMapRootClasses().get(invSuper.getClassname()); |
|
|
|
|
|
|
|
|
|
|
|
ClassNode newnode = DecompilerContext.getClassProcessor().getMapRootClasses().get(invsuper.getClassname()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<VarVersionPair> sigFields = null; |
|
|
|
List<VarVersionPair> sigFields = null; |
|
|
|
if (newnode != null) { // own class
|
|
|
|
if (newNode != null) { // own class
|
|
|
|
if (newnode.getWrapper() != null) { |
|
|
|
if (newNode.getWrapper() != null) { |
|
|
|
sigFields = newnode.getWrapper().getMethodWrapper(CodeConstants.INIT_NAME, invsuper.getStringDescriptor()).signatureFields; |
|
|
|
sigFields = newNode.getWrapper().getMethodWrapper(CodeConstants.INIT_NAME, invSuper.getStringDescriptor()).signatureFields; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (newnode.type == ClassNode.CLASS_MEMBER && (newnode.access & CodeConstants.ACC_STATIC) == 0 && |
|
|
|
if (newNode.type == ClassNode.CLASS_MEMBER && (newNode.access & CodeConstants.ACC_STATIC) == 0 && |
|
|
|
!constructor.getLstParameters().isEmpty()) { // member non-static class invoked with enclosing class instance
|
|
|
|
!constructor.getLstParameters().isEmpty()) { // member non-static class invoked with enclosing class instance
|
|
|
|
sigFields = new ArrayList<VarVersionPair>(Collections.nCopies(constructor.getLstParameters().size(), (VarVersionPair)null)); |
|
|
|
sigFields = new ArrayList<VarVersionPair>(Collections.nCopies(constructor.getLstParameters().size(), (VarVersionPair)null)); |
|
|
|
sigFields.set(0, new VarVersionPair(-1, 0)); |
|
|
|
sigFields.set(0, new VarVersionPair(-1, 0)); |
|
|
@ -188,31 +180,29 @@ public class NewExprent extends Exprent { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
boolean firstpar = true; |
|
|
|
boolean firstParam = true; |
|
|
|
int start = 0, end = invsuper.getLstParameters().size(); |
|
|
|
int start = 0, end = invSuper.getLstParameters().size(); |
|
|
|
if (enumConst) { |
|
|
|
if (enumConst) { |
|
|
|
start += 2; |
|
|
|
start += 2; |
|
|
|
end -= 1; |
|
|
|
end -= 1; |
|
|
|
} |
|
|
|
} |
|
|
|
for (int i = start; i < end; i++) { |
|
|
|
for (int i = start; i < end; i++) { |
|
|
|
if (sigFields == null || sigFields.get(i) == null) { |
|
|
|
if (sigFields == null || sigFields.get(i) == null) { |
|
|
|
if (!firstpar) { |
|
|
|
if (!firstParam) { |
|
|
|
buf.append(", "); |
|
|
|
buf.append(", "); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Exprent param = invsuper.getLstParameters().get(i); |
|
|
|
Exprent param = invSuper.getLstParameters().get(i); |
|
|
|
if (param.type == Exprent.EXPRENT_VAR) { |
|
|
|
if (param.type == Exprent.EXPRENT_VAR) { |
|
|
|
int varindex = ((VarExprent)param).getIndex(); |
|
|
|
int varIndex = ((VarExprent)param).getIndex(); |
|
|
|
if (varindex > 0 && varindex <= constructor.getLstParameters().size()) { |
|
|
|
if (varIndex > 0 && varIndex <= constructor.getLstParameters().size()) { |
|
|
|
param = constructor.getLstParameters().get(varindex - 1); |
|
|
|
param = constructor.getLstParameters().get(varIndex - 1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TextBuffer buff = new TextBuffer(); |
|
|
|
ExprProcessor.getCastedExprent(param, invSuper.getDescriptor().params[i], buf, indent, true, tracer); |
|
|
|
ExprProcessor.getCastedExprent(param, invsuper.getDescriptor().params[i], buff, indent, true, tracer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buf.append(buff); |
|
|
|
firstParam = false; |
|
|
|
firstpar = false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -226,14 +216,15 @@ public class NewExprent extends Exprent { |
|
|
|
String typename = ExprProcessor.getCastTypeName(child.anonymousClassType); |
|
|
|
String typename = ExprProcessor.getCastTypeName(child.anonymousClassType); |
|
|
|
|
|
|
|
|
|
|
|
if (enclosing != null) { |
|
|
|
if (enclosing != null) { |
|
|
|
ClassNode anonimousNode = DecompilerContext.getClassProcessor().getMapRootClasses().get(child.anonymousClassType.value); |
|
|
|
ClassNode anonymousNode = DecompilerContext.getClassProcessor().getMapRootClasses().get(child.anonymousClassType.value); |
|
|
|
if (anonimousNode != null) { |
|
|
|
if (anonymousNode != null) { |
|
|
|
typename = anonimousNode.simpleName; |
|
|
|
typename = anonymousNode.simpleName; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
typename = typename.substring(typename.lastIndexOf('.') + 1); |
|
|
|
typename = typename.substring(typename.lastIndexOf('.') + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
buf.prepend("new " + typename); |
|
|
|
buf.prepend("new " + typename); |
|
|
|
|
|
|
|
|
|
|
|
if (enclosing != null) { |
|
|
|
if (enclosing != null) { |
|
|
@ -275,118 +266,108 @@ public class NewExprent extends Exprent { |
|
|
|
} |
|
|
|
} |
|
|
|
buf.append("}"); |
|
|
|
buf.append("}"); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else if (newType.arrayDim == 0) { |
|
|
|
if (newType.arrayDim == 0) { |
|
|
|
if (constructor != null) { |
|
|
|
|
|
|
|
List<Exprent> lstParameters = constructor.getLstParameters(); |
|
|
|
|
|
|
|
|
|
|
|
if (constructor != null) { |
|
|
|
ClassNode newNode = DecompilerContext.getClassProcessor().getMapRootClasses().get(constructor.getClassname()); |
|
|
|
|
|
|
|
|
|
|
|
List<Exprent> lstParameters = constructor.getLstParameters(); |
|
|
|
List<VarVersionPair> sigFields = null; |
|
|
|
|
|
|
|
if (newNode != null) { // own class
|
|
|
|
|
|
|
|
if (newNode.getWrapper() != null) { |
|
|
|
|
|
|
|
sigFields = newNode.getWrapper().getMethodWrapper(CodeConstants.INIT_NAME, constructor.getStringDescriptor()).signatureFields; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (newNode.type == ClassNode.CLASS_MEMBER && (newNode.access & CodeConstants.ACC_STATIC) == 0 && !constructor.getLstParameters().isEmpty()) { |
|
|
|
|
|
|
|
// member non-static class invoked with enclosing class instance
|
|
|
|
|
|
|
|
sigFields = new ArrayList<VarVersionPair>(Collections.nCopies(lstParameters.size(), (VarVersionPair)null)); |
|
|
|
|
|
|
|
sigFields.set(0, new VarVersionPair(-1, 0)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ClassNode newnode = DecompilerContext.getClassProcessor().getMapRootClasses().get(constructor.getClassname()); |
|
|
|
int start = enumConst ? 2 : 0; |
|
|
|
|
|
|
|
if (!enumConst || start < lstParameters.size()) { |
|
|
|
|
|
|
|
buf.append("("); |
|
|
|
|
|
|
|
|
|
|
|
List<VarVersionPair> sigFields = null; |
|
|
|
boolean firstParam = true; |
|
|
|
if (newnode != null) { // own class
|
|
|
|
for (int i = start; i < lstParameters.size(); i++) { |
|
|
|
if (newnode.getWrapper() != null) { |
|
|
|
if (sigFields == null || sigFields.get(i) == null) { |
|
|
|
sigFields = newnode.getWrapper().getMethodWrapper(CodeConstants.INIT_NAME, constructor.getStringDescriptor()).signatureFields; |
|
|
|
Exprent expr = lstParameters.get(i); |
|
|
|
} |
|
|
|
VarType leftType = constructor.getDescriptor().params[i]; |
|
|
|
else { |
|
|
|
|
|
|
|
if (newnode.type == ClassNode.CLASS_MEMBER && (newnode.access & CodeConstants.ACC_STATIC) == 0 && |
|
|
|
|
|
|
|
!constructor.getLstParameters().isEmpty()) { // member non-static class invoked with enclosing class instance
|
|
|
|
|
|
|
|
sigFields = new ArrayList<VarVersionPair>(Collections.nCopies(lstParameters.size(), (VarVersionPair)null)); |
|
|
|
|
|
|
|
sigFields.set(0, new VarVersionPair(-1, 0)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int start = enumConst ? 2 : 0; |
|
|
|
if (i == lstParameters.size() - 1 && expr.getExprType() == VarType.VARTYPE_NULL) { |
|
|
|
if (!enumConst || start < lstParameters.size()) { |
|
|
|
ClassNode node = DecompilerContext.getClassProcessor().getMapRootClasses().get(leftType.value); |
|
|
|
buf.append("("); |
|
|
|
if (node != null && node.namelessConstructorStub) { |
|
|
|
|
|
|
|
break; // skip last parameter of synthetic constructor call
|
|
|
|
boolean firstParam = true; |
|
|
|
|
|
|
|
for (int i = start; i < lstParameters.size(); i++) { |
|
|
|
|
|
|
|
if (sigFields == null || sigFields.get(i) == null) { |
|
|
|
|
|
|
|
Exprent expr = lstParameters.get(i); |
|
|
|
|
|
|
|
VarType leftType = constructor.getDescriptor().params[i]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i == lstParameters.size() - 1 && expr.getExprType() == VarType.VARTYPE_NULL) { |
|
|
|
|
|
|
|
ClassNode node = DecompilerContext.getClassProcessor().getMapRootClasses().get(leftType.value); |
|
|
|
|
|
|
|
if (node != null && node.namelessConstructorStub) { |
|
|
|
|
|
|
|
break; // skip last parameter of synthetic constructor call
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!firstParam) { |
|
|
|
if (!firstParam) { |
|
|
|
buf.append(", "); |
|
|
|
buf.append(", "); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TextBuffer buff = new TextBuffer(); |
|
|
|
ExprProcessor.getCastedExprent(expr, leftType, buf, indent, true, tracer); |
|
|
|
ExprProcessor.getCastedExprent(expr, leftType, buff, indent, true, tracer); |
|
|
|
|
|
|
|
buf.append(buff); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
firstParam = false; |
|
|
|
firstParam = false; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
buf.append(")"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buf.append(")"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!enumConst) { |
|
|
|
if (!enumConst) { |
|
|
|
String enclosing = null; |
|
|
|
String enclosing = null; |
|
|
|
if (constructor != null) { |
|
|
|
if (constructor != null) { |
|
|
|
enclosing = getQualifiedNewInstance(newType.value, constructor.getLstParameters(), indent, tracer); |
|
|
|
enclosing = getQualifiedNewInstance(newType.value, constructor.getLstParameters(), indent, tracer); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String typename = ExprProcessor.getTypeName(newType); |
|
|
|
String typename = ExprProcessor.getTypeName(newType); |
|
|
|
|
|
|
|
|
|
|
|
if (enclosing != null) { |
|
|
|
if (enclosing != null) { |
|
|
|
ClassNode newNode = DecompilerContext.getClassProcessor().getMapRootClasses().get(newType.value); |
|
|
|
ClassNode newNode = DecompilerContext.getClassProcessor().getMapRootClasses().get(newType.value); |
|
|
|
if (newNode != null) { |
|
|
|
if (newNode != null) { |
|
|
|
typename = newNode.simpleName; |
|
|
|
typename = newNode.simpleName; |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
typename = typename.substring(typename.lastIndexOf('.') + 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
buf.prepend("new " + typename); |
|
|
|
else { |
|
|
|
|
|
|
|
typename = typename.substring(typename.lastIndexOf('.') + 1); |
|
|
|
if (enclosing != null) { |
|
|
|
|
|
|
|
buf.prepend(enclosing + "."); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
buf.prepend("new " + typename); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (enclosing != null) { |
|
|
|
|
|
|
|
buf.prepend(enclosing + "."); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} |
|
|
|
buf.append("new ").append(ExprProcessor.getTypeName(newType)); |
|
|
|
else { |
|
|
|
|
|
|
|
buf.append("new ").append(ExprProcessor.getTypeName(newType)); |
|
|
|
|
|
|
|
|
|
|
|
if (lstArrayElements.isEmpty()) { |
|
|
|
if (lstArrayElements.isEmpty()) { |
|
|
|
for (int i = 0; i < newType.arrayDim; i++) { |
|
|
|
for (int i = 0; i < newType.arrayDim; i++) { |
|
|
|
buf.append("["); |
|
|
|
buf.append("["); |
|
|
|
if (i < lstDims.size()) { |
|
|
|
if (i < lstDims.size()) { |
|
|
|
buf.append(lstDims.get(i).toJava(indent, tracer)); |
|
|
|
buf.append(lstDims.get(i).toJava(indent, tracer)); |
|
|
|
} |
|
|
|
|
|
|
|
buf.append("]"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
buf.append("]"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
for (int i = 0; i < newType.arrayDim; i++) { |
|
|
|
|
|
|
|
buf.append("[]"); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
|
for (int i = 0; i < newType.arrayDim; i++) { |
|
|
|
|
|
|
|
buf.append("[]"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VarType leftType = newType.decreaseArrayDim(); |
|
|
|
|
|
|
|
buf.append("{"); |
|
|
|
|
|
|
|
for (int i = 0; i < lstArrayElements.size(); i++) { |
|
|
|
|
|
|
|
if (i > 0) { |
|
|
|
|
|
|
|
buf.append(", "); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
TextBuffer buff = new TextBuffer(); |
|
|
|
|
|
|
|
ExprProcessor.getCastedExprent(lstArrayElements.get(i), leftType, buff, indent, false, tracer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buf.append(buff); |
|
|
|
VarType leftType = newType.decreaseArrayDim(); |
|
|
|
|
|
|
|
buf.append("{"); |
|
|
|
|
|
|
|
for (int i = 0; i < lstArrayElements.size(); i++) { |
|
|
|
|
|
|
|
if (i > 0) { |
|
|
|
|
|
|
|
buf.append(", "); |
|
|
|
} |
|
|
|
} |
|
|
|
buf.append("}"); |
|
|
|
ExprProcessor.getCastedExprent(lstArrayElements.get(i), leftType, buf, indent, false, tracer); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
buf.append("}"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return buf; |
|
|
|
return buf; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|