java-decompiler: cleanups and fixes
- duplicates eliminated - immutable fields - typos - formatting
This commit is contained in:
@@ -89,7 +89,7 @@ public class AssertProcessor {
|
||||
if (initializer.type == Exprent.EXPRENT_FUNCTION) {
|
||||
FunctionExprent fexpr = (FunctionExprent)initializer;
|
||||
|
||||
if (fexpr.getFunctype() == FunctionExprent.FUNCTION_BOOLNOT &&
|
||||
if (fexpr.getFuncType() == FunctionExprent.FUNCTION_BOOL_NOT &&
|
||||
fexpr.getLstOperands().get(0).type == Exprent.EXPRENT_INVOCATION) {
|
||||
|
||||
InvocationExprent invexpr = (InvocationExprent)fexpr.getLstOperands().get(0);
|
||||
@@ -101,7 +101,7 @@ public class AssertProcessor {
|
||||
invexpr.getLstParameters().isEmpty()) {
|
||||
|
||||
ConstExprent cexpr = (ConstExprent)invexpr.getInstance();
|
||||
if (VarType.VARTYPE_CLASS.equals(cexpr.getConsttype())) {
|
||||
if (VarType.VARTYPE_CLASS.equals(cexpr.getConstType())) {
|
||||
|
||||
ClassNode nd = node;
|
||||
while (nd != null) {
|
||||
@@ -173,7 +173,7 @@ public class AssertProcessor {
|
||||
|
||||
Exprent ascond = null, retcond = null;
|
||||
if (exprres[0] != null) {
|
||||
ascond = new FunctionExprent(FunctionExprent.FUNCTION_BOOLNOT,
|
||||
ascond = new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT,
|
||||
Arrays.asList((Exprent)exprres[0]), throwError.bytecode);
|
||||
retcond = SecondaryFunctionsHelper.propagateBoolNot(ascond);
|
||||
}
|
||||
@@ -245,9 +245,9 @@ public class AssertProcessor {
|
||||
|
||||
if (expr.type == Exprent.EXPRENT_EXIT) {
|
||||
ExitExprent exexpr = (ExitExprent)expr;
|
||||
if (exexpr.getExittype() == ExitExprent.EXIT_THROW && exexpr.getValue().type == Exprent.EXPRENT_NEW) {
|
||||
if (exexpr.getExitType() == ExitExprent.EXIT_THROW && exexpr.getValue().type == Exprent.EXPRENT_NEW) {
|
||||
NewExprent nexpr = (NewExprent)exexpr.getValue();
|
||||
if (CLASS_ASSERTION_ERROR.equals(nexpr.getNewtype()) && nexpr.getConstructor() != null) {
|
||||
if (CLASS_ASSERTION_ERROR.equals(nexpr.getNewType()) && nexpr.getConstructor() != null) {
|
||||
return nexpr.getConstructor();
|
||||
}
|
||||
}
|
||||
@@ -260,7 +260,7 @@ public class AssertProcessor {
|
||||
|
||||
if (exprent.type == Exprent.EXPRENT_FUNCTION) {
|
||||
FunctionExprent fexpr = (FunctionExprent)exprent;
|
||||
if (fexpr.getFunctype() == FunctionExprent.FUNCTION_CADD) {
|
||||
if (fexpr.getFuncType() == FunctionExprent.FUNCTION_CADD) {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Exprent param = fexpr.getLstOperands().get(i);
|
||||
@@ -295,7 +295,7 @@ public class AssertProcessor {
|
||||
|
||||
if (exprent.type == Exprent.EXPRENT_FUNCTION) {
|
||||
FunctionExprent fparam = (FunctionExprent)exprent;
|
||||
if (fparam.getFunctype() == FunctionExprent.FUNCTION_BOOLNOT &&
|
||||
if (fparam.getFuncType() == FunctionExprent.FUNCTION_BOOL_NOT &&
|
||||
fparam.getLstOperands().get(0).type == Exprent.EXPRENT_FIELD) {
|
||||
FieldExprent fdparam = (FieldExprent)fparam.getLstOperands().get(0);
|
||||
if (classname.equals(fdparam.getClassname())
|
||||
|
||||
@@ -190,7 +190,7 @@ public class ClassReference14Processor {
|
||||
CatchStatement cst = (CatchStatement)root.getFirst();
|
||||
if (cst.getStats().size() == 2 && cst.getFirst().type == Statement.TYPE_BASICBLOCK &&
|
||||
cst.getStats().get(1).type == Statement.TYPE_BASICBLOCK &&
|
||||
cst.getVars().get(0).getVartype().equals(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/ClassNotFoundException"))) {
|
||||
cst.getVars().get(0).getVarType().equals(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/ClassNotFoundException"))) {
|
||||
|
||||
BasicBlockStatement body = (BasicBlockStatement)cst.getFirst();
|
||||
BasicBlockStatement handler = (BasicBlockStatement)cst.getStats().get(1);
|
||||
@@ -247,13 +247,13 @@ public class ClassReference14Processor {
|
||||
|
||||
if (exprent.type == Exprent.EXPRENT_FUNCTION) {
|
||||
FunctionExprent fexpr = (FunctionExprent)exprent;
|
||||
if (fexpr.getFunctype() == FunctionExprent.FUNCTION_IIF) {
|
||||
if (fexpr.getFuncType() == FunctionExprent.FUNCTION_IIF) {
|
||||
if (fexpr.getLstOperands().get(0).type == Exprent.EXPRENT_FUNCTION) {
|
||||
FunctionExprent headexpr = (FunctionExprent)fexpr.getLstOperands().get(0);
|
||||
if (headexpr.getFunctype() == FunctionExprent.FUNCTION_EQ) {
|
||||
if (headexpr.getFuncType() == FunctionExprent.FUNCTION_EQ) {
|
||||
if (headexpr.getLstOperands().get(0).type == Exprent.EXPRENT_FIELD &&
|
||||
headexpr.getLstOperands().get(1).type == Exprent.EXPRENT_CONST &&
|
||||
((ConstExprent)headexpr.getLstOperands().get(1)).getConsttype().equals(VarType.VARTYPE_NULL)) {
|
||||
((ConstExprent)headexpr.getLstOperands().get(1)).getConstType().equals(VarType.VARTYPE_NULL)) {
|
||||
|
||||
FieldExprent field = (FieldExprent)headexpr.getLstOperands().get(0);
|
||||
ClassNode fieldnode = DecompilerContext.getClassProcessor().getMapRootClasses().get(field.getClassname());
|
||||
|
||||
@@ -136,7 +136,7 @@ public class ClassWriter {
|
||||
firstParameter = false;
|
||||
}
|
||||
|
||||
index += md_content.params[i].stack_size;
|
||||
index += md_content.params[i].stackSize;
|
||||
}
|
||||
|
||||
buffer.append(") ->");
|
||||
@@ -440,7 +440,7 @@ public class ClassWriter {
|
||||
if (initializer != null) {
|
||||
if (isEnum && initializer.type == Exprent.EXPRENT_NEW) {
|
||||
NewExprent nexpr = (NewExprent)initializer;
|
||||
nexpr.setEnumconst(true);
|
||||
nexpr.setEnumConst(true);
|
||||
buffer.append(nexpr.toJava(indent, tracer));
|
||||
}
|
||||
else {
|
||||
@@ -512,7 +512,7 @@ public class ClassWriter {
|
||||
firstParameter = false;
|
||||
}
|
||||
|
||||
index += md_content.params[i].stack_size;
|
||||
index += md_content.params[i].stackSize;
|
||||
}
|
||||
|
||||
buffer.append(") {").appendLineSeparator();
|
||||
@@ -692,16 +692,16 @@ public class ClassWriter {
|
||||
|
||||
appendParameterAnnotations(buffer, mt, paramCount);
|
||||
|
||||
if (methodWrapper.varproc.getVarFinal(new VarVersionPaar(index, 0)) == VarTypeProcessor.VAR_FINALEXPLICIT) {
|
||||
if (methodWrapper.varproc.getVarFinal(new VarVersionPaar(index, 0)) == VarTypeProcessor.VAR_EXPLICIT_FINAL) {
|
||||
buffer.append("final ");
|
||||
}
|
||||
|
||||
if (descriptor != null) {
|
||||
GenericType parameterType = descriptor.params.get(i);
|
||||
|
||||
boolean isVarArg = (i == lastVisibleParameterIndex && mt.hasModifier(CodeConstants.ACC_VARARGS) && parameterType.arraydim > 0);
|
||||
boolean isVarArg = (i == lastVisibleParameterIndex && mt.hasModifier(CodeConstants.ACC_VARARGS) && parameterType.arrayDim > 0);
|
||||
if (isVarArg) {
|
||||
parameterType.arraydim--;
|
||||
parameterType = parameterType.decreaseArrayDim();
|
||||
}
|
||||
|
||||
String typeName = GenericMain.getGenericCastTypeName(parameterType);
|
||||
@@ -717,11 +717,11 @@ public class ClassWriter {
|
||||
}
|
||||
}
|
||||
else {
|
||||
VarType parameterType = md.params[i].copy();
|
||||
VarType parameterType = md.params[i];
|
||||
|
||||
boolean isVarArg = (i == lastVisibleParameterIndex && mt.hasModifier(CodeConstants.ACC_VARARGS) && parameterType.arraydim > 0);
|
||||
boolean isVarArg = (i == lastVisibleParameterIndex && mt.hasModifier(CodeConstants.ACC_VARARGS) && parameterType.arrayDim > 0);
|
||||
if (isVarArg) {
|
||||
parameterType.decArrayDim();
|
||||
parameterType = parameterType.decreaseArrayDim();
|
||||
}
|
||||
|
||||
String typeName = ExprProcessor.getCastTypeName(parameterType);
|
||||
@@ -745,7 +745,7 @@ public class ClassWriter {
|
||||
paramCount++;
|
||||
}
|
||||
|
||||
index += md.params[i].stack_size;
|
||||
index += md.params[i].stackSize;
|
||||
}
|
||||
|
||||
buffer.append(')');
|
||||
@@ -839,7 +839,7 @@ public class ClassWriter {
|
||||
return !hideMethod;
|
||||
}
|
||||
|
||||
private void mapLines(TextBuffer code, StructLineNumberTableAttribute table, BytecodeMappingTracer tracer, int startLine) {
|
||||
private static void mapLines(TextBuffer code, StructLineNumberTableAttribute table, BytecodeMappingTracer tracer, int startLine) {
|
||||
// build line start offsets map
|
||||
HashMap<Integer, Set<Integer>> lineStartOffsets = new HashMap<Integer, Set<Integer>>();
|
||||
for (Map.Entry<Integer, Integer> entry : tracer.getMapping().entrySet()) {
|
||||
|
||||
@@ -103,7 +103,7 @@ public class EnumProcessor {
|
||||
VarExprent instvar = (VarExprent)inv.getInstance();
|
||||
VarVersionPaar varpaar = new VarVersionPaar(instvar);
|
||||
|
||||
String classname = meth.varproc.getThisvars().get(varpaar);
|
||||
String classname = meth.varproc.getThisVars().get(varpaar);
|
||||
|
||||
if (classname != null) { // any this instance. TODO: Restrict to current class?
|
||||
if (!wrapper.getClassStruct().qualifiedName.equals(inv.getClassname())) {
|
||||
|
||||
@@ -261,7 +261,7 @@ public class InitializerProcessor {
|
||||
switch (expr.type) {
|
||||
case Exprent.EXPRENT_VAR:
|
||||
VarVersionPaar varpaar = new VarVersionPaar((VarExprent)expr);
|
||||
if (!meth.varproc.getExternvars().contains(varpaar)) {
|
||||
if (!meth.varproc.getExternalVars().contains(varpaar)) {
|
||||
String varname = meth.varproc.getVarName(varpaar);
|
||||
|
||||
if (!varname.equals("this") && !varname.endsWith(".this")) { // FIXME: remove direct comparison with strings
|
||||
@@ -308,7 +308,7 @@ public class InitializerProcessor {
|
||||
VarExprent instvar = (VarExprent)inv.getInstance();
|
||||
VarVersionPaar varpaar = new VarVersionPaar(instvar);
|
||||
|
||||
String classname = meth.varproc.getThisvars().get(varpaar);
|
||||
String classname = meth.varproc.getThisVars().get(varpaar);
|
||||
|
||||
if (classname != null) { // any this instance. TODO: Restrict to current class?
|
||||
if (withThis || !wrapper.getClassStruct().qualifiedName.equals(inv.getClassname())) {
|
||||
|
||||
@@ -124,7 +124,7 @@ public class ClassWrapper {
|
||||
|
||||
int paramcount = 0;
|
||||
if (thisvar) {
|
||||
varproc.getThisvars().put(new VarVersionPaar(0, 0), classStruct.qualifiedName);
|
||||
varproc.getThisVars().put(new VarVersionPaar(0, 0), classStruct.qualifiedName);
|
||||
paramcount = 1;
|
||||
}
|
||||
paramcount += md.params.length;
|
||||
@@ -138,11 +138,11 @@ public class ClassWrapper {
|
||||
varindex++;
|
||||
}
|
||||
else {
|
||||
varindex += md.params[i - 1].stack_size;
|
||||
varindex += md.params[i - 1].stackSize;
|
||||
}
|
||||
}
|
||||
else {
|
||||
varindex += md.params[i].stack_size;
|
||||
varindex += md.params[i].stackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class NestedClassProcessor {
|
||||
|
||||
// this pointer
|
||||
if (!is_static_lambda_content && DecompilerContext.getOption(IFernflowerPreferences.LAMBDA_TO_ANONYMOUS_CLASS)) {
|
||||
meth.varproc.getThisvars().put(new VarVersionPaar(0, 0), parent_class_name);
|
||||
meth.varproc.getThisVars().put(new VarVersionPaar(0, 0), parent_class_name);
|
||||
meth.varproc.setVarName(new VarVersionPaar(0, 0), parent.simpleName + ".this");
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public class NestedClassProcessor {
|
||||
|
||||
if (expr.type == Exprent.EXPRENT_NEW) {
|
||||
NewExprent new_expr = (NewExprent)expr;
|
||||
if (new_expr.isLambda() && lambda_class_type.equals(new_expr.getNewtype())) {
|
||||
if (new_expr.isLambda() && lambda_class_type.equals(new_expr.getNewType())) {
|
||||
|
||||
InvocationExprent inv_dynamic = new_expr.getConstructor();
|
||||
|
||||
@@ -165,7 +165,7 @@ public class NestedClassProcessor {
|
||||
mapNewNames.put(new VarVersionPaar(varindex, 0), enc_varname);
|
||||
}
|
||||
|
||||
varindex += md_content.params[i].stack_size;
|
||||
varindex += md_content.params[i].stackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,7 +330,7 @@ public class NestedClassProcessor {
|
||||
VarVersionPaar varpaar = new VarVersionPaar((VarExprent)param);
|
||||
|
||||
// FIXME: final flags of variables are wrong! Correct the entire final functionality.
|
||||
// if(meth.varproc.getVarFinal(varpaar) != VarTypeProcessor.VAR_NONFINAL) {
|
||||
// if(meth.varproc.getVarFinal(varpaar) != VarTypeProcessor.VAR_NON_FINAL) {
|
||||
pair = new VarFieldPair(mask.get(i).keyfield, varpaar);
|
||||
// }
|
||||
}
|
||||
@@ -467,7 +467,7 @@ public class NestedClassProcessor {
|
||||
varname = encmeth.varproc.getVarName(paar);
|
||||
vartype = encmeth.varproc.getVarType(paar);
|
||||
|
||||
encmeth.varproc.setVarFinal(paar, VarTypeProcessor.VAR_FINALEXPLICIT);
|
||||
encmeth.varproc.setVarFinal(paar, VarTypeProcessor.VAR_EXPLICIT_FINAL);
|
||||
}
|
||||
|
||||
if (paar.var == -1 || "this".equals(varname)) {
|
||||
@@ -478,13 +478,13 @@ public class NestedClassProcessor {
|
||||
else {
|
||||
varname = parent.simpleName + ".this";
|
||||
}
|
||||
meth.varproc.getThisvars().put(newvar, parent.classStruct.qualifiedName);
|
||||
meth.varproc.getThisVars().put(newvar, parent.classStruct.qualifiedName);
|
||||
}
|
||||
|
||||
mapNewNames.put(newvar, varname);
|
||||
mapNewTypes.put(newvar, vartype);
|
||||
}
|
||||
varindex += md.params[index++].stack_size;
|
||||
varindex += md.params[index++].stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ public class NestedClassProcessor {
|
||||
varname = enclosing_method.varproc.getVarName(entr.getValue());
|
||||
vartype = enclosing_method.varproc.getVarType(entr.getValue());
|
||||
|
||||
enclosing_method.varproc.setVarFinal(entr.getValue(), VarTypeProcessor.VAR_FINALEXPLICIT);
|
||||
enclosing_method.varproc.setVarFinal(entr.getValue(), VarTypeProcessor.VAR_EXPLICIT_FINAL);
|
||||
}
|
||||
|
||||
if (entr.getValue().var == -1 || "this".equals(varname)) {
|
||||
@@ -519,7 +519,7 @@ public class NestedClassProcessor {
|
||||
else {
|
||||
varname = clnode.parent.simpleName + ".this";
|
||||
}
|
||||
meth.varproc.getThisvars().put(newvar, clnode.parent.classStruct.qualifiedName);
|
||||
meth.varproc.getThisVars().put(newvar, clnode.parent.classStruct.qualifiedName);
|
||||
}
|
||||
|
||||
mapNewNames.put(newvar, varname);
|
||||
@@ -594,7 +594,7 @@ public class NestedClassProcessor {
|
||||
int varindex = ((VarExprent)exprent).getIndex();
|
||||
if (mapParamsToNewVars.containsKey(varindex)) {
|
||||
VarVersionPaar newvar = mapParamsToNewVars.get(varindex);
|
||||
meth.varproc.getExternvars().add(newvar);
|
||||
meth.varproc.getExternalVars().add(newvar);
|
||||
return new VarExprent(newvar.var, meth.varproc.getVarType(newvar), meth.varproc);
|
||||
}
|
||||
}
|
||||
@@ -608,7 +608,7 @@ public class NestedClassProcessor {
|
||||
//if(fexpr.getClassname().equals(child.classStruct.qualifiedName) &&
|
||||
// mapFieldsToNewVars.containsKey(keyField)) {
|
||||
VarVersionPaar newvar = mapFieldsToNewVars.get(keyField);
|
||||
meth.varproc.getExternvars().add(newvar);
|
||||
meth.varproc.getExternalVars().add(newvar);
|
||||
return new VarExprent(newvar.var, meth.varproc.getVarType(newvar), meth.varproc);
|
||||
}
|
||||
}
|
||||
@@ -656,7 +656,7 @@ public class NestedClassProcessor {
|
||||
for (int i = 0; i < md.params.length; i++) { // no static methods allowed
|
||||
String keyField = getEnclosingVarField(cl, meth, graph, varindex);
|
||||
fields.add(keyField == null ? null : new VarFieldPair(keyField, new VarVersionPaar(-1, 0))); // TODO: null?
|
||||
varindex += md.params[i].stack_size;
|
||||
varindex += md.params[i].stackSize;
|
||||
}
|
||||
mapMasks.put(mt.getDescriptor(), fields);
|
||||
}
|
||||
@@ -671,7 +671,7 @@ public class NestedClassProcessor {
|
||||
String field = "";
|
||||
|
||||
// parameter variable final
|
||||
if (meth.varproc.getVarFinal(new VarVersionPaar(index, 0)) == VarTypeProcessor.VAR_NONFINAL) {
|
||||
if (meth.varproc.getVarFinal(new VarVersionPaar(index, 0)) == VarTypeProcessor.VAR_NON_FINAL) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -854,7 +854,7 @@ public class NestedClassProcessor {
|
||||
VarExprent var = new VarExprent(meth.counter.getCounterAndIncrement(CounterContainer.VAR_COUNTER),
|
||||
classtype, meth.varproc);
|
||||
var.setDefinition(true);
|
||||
var.setClassdef(true);
|
||||
var.setClassDef(true);
|
||||
|
||||
lst.add(addindex, var);
|
||||
}
|
||||
@@ -970,8 +970,8 @@ public class NestedClassProcessor {
|
||||
switch (expr.type) {
|
||||
case Exprent.EXPRENT_CONST:
|
||||
ConstExprent cexpr = (ConstExprent)expr;
|
||||
res = (VarType.VARTYPE_CLASS.equals(cexpr.getConsttype()) && classname.equals(cexpr.getValue()) ||
|
||||
classtype.equals(cexpr.getConsttype()));
|
||||
res = (VarType.VARTYPE_CLASS.equals(cexpr.getConstType()) && classname.equals(cexpr.getValue()) ||
|
||||
classtype.equals(cexpr.getConstType()));
|
||||
break;
|
||||
case Exprent.EXPRENT_FIELD:
|
||||
res = classname.equals(((FieldExprent)expr).getClassname());
|
||||
@@ -986,8 +986,8 @@ public class NestedClassProcessor {
|
||||
case Exprent.EXPRENT_VAR:
|
||||
VarExprent vexpr = (VarExprent)expr;
|
||||
if (vexpr.isDefinition()) {
|
||||
VarType vtype = vexpr.getVartype();
|
||||
if (classtype.equals(vtype) || (vtype.arraydim > 0 && classtype.value.equals(vtype.value))) {
|
||||
VarType vtype = vexpr.getVarType();
|
||||
if (classtype.equals(vtype) || (vtype.arrayDim > 0 && classtype.value.equals(vtype.value))) {
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class NestedMemberAccess {
|
||||
|
||||
if (exprent.type == Exprent.EXPRENT_EXIT) {
|
||||
ExitExprent exexpr = (ExitExprent)exprent;
|
||||
if (exexpr.getExittype() == ExitExprent.EXIT_RETURN && exexpr.getValue() != null) {
|
||||
if (exexpr.getExitType() == ExitExprent.EXIT_RETURN && exexpr.getValue() != null) {
|
||||
exprCore = exexpr.getValue();
|
||||
}
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public class NestedMemberAccess {
|
||||
if (((VarExprent)asexpr.getRight()).getIndex() == parcount - 1) {
|
||||
|
||||
ExitExprent exexpr = (ExitExprent)exprentSecond;
|
||||
if (exexpr.getExittype() == ExitExprent.EXIT_RETURN && exexpr.getValue() != null) {
|
||||
if (exexpr.getExitType() == ExitExprent.EXIT_RETURN && exexpr.getValue() != null) {
|
||||
if (exexpr.getValue().type == Exprent.EXPRENT_VAR &&
|
||||
((VarExprent)asexpr.getRight()).getIndex() == parcount - 1) {
|
||||
type = METHOD_ACCESS_FIELD_SET;
|
||||
@@ -375,7 +375,7 @@ public class NestedMemberAccess {
|
||||
}
|
||||
|
||||
int index = methdest.counter.getCounterAndIncrement(CounterContainer.VAR_COUNTER);
|
||||
VarExprent ret = new VarExprent(index, var.getVartype(), methdest.varproc);
|
||||
VarExprent ret = new VarExprent(index, var.getVarType(), methdest.varproc);
|
||||
methdest.varproc.setVarName(new VarVersionPaar(index, 0), varname);
|
||||
|
||||
retexprent = ret;
|
||||
|
||||
Reference in New Issue
Block a user