|
|
@ -22,6 +22,8 @@ import jode.*; |
|
|
|
import jode.bytecode.*; |
|
|
|
import jode.bytecode.*; |
|
|
|
import jode.flow.FlowBlock; |
|
|
|
import jode.flow.FlowBlock; |
|
|
|
import jode.flow.TransformExceptionHandlers; |
|
|
|
import jode.flow.TransformExceptionHandlers; |
|
|
|
|
|
|
|
import jode.jvm.CodeVerifier; |
|
|
|
|
|
|
|
import jode.jvm.VerifyException; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.BitSet; |
|
|
|
import java.util.BitSet; |
|
|
|
import java.util.Stack; |
|
|
|
import java.util.Stack; |
|
|
@ -48,7 +50,7 @@ public class CodeAnalyzer implements Analyzer { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public MethodAnalyzer getMethod() {return method;} |
|
|
|
public MethodAnalyzer getMethod() {return method;} |
|
|
|
|
|
|
|
|
|
|
|
public CodeAnalyzer(MethodAnalyzer ma, |
|
|
|
public CodeAnalyzer(MethodAnalyzer ma, MethodInfo minfo, |
|
|
|
AttributeInfo codeattr, JodeEnvironment e) |
|
|
|
AttributeInfo codeattr, JodeEnvironment e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
method = ma; |
|
|
|
method = ma; |
|
|
@ -65,6 +67,14 @@ public class CodeAnalyzer implements Analyzer { |
|
|
|
code = null; |
|
|
|
code = null; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
CodeVerifier verifier |
|
|
|
|
|
|
|
= new CodeVerifier(getClazz(), minfo, code); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
verifier.verify(); |
|
|
|
|
|
|
|
} catch (VerifyException ex) { |
|
|
|
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
|
|
|
throw new jode.AssertError("Verification error"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (Decompiler.useLVT) { |
|
|
|
if (Decompiler.useLVT) { |
|
|
|
AttributeInfo attr = code.findAttribute("LocalVariableTable"); |
|
|
|
AttributeInfo attr = code.findAttribute("LocalVariableTable"); |
|
|
@ -74,11 +84,22 @@ public class CodeAnalyzer implements Analyzer { |
|
|
|
lvt = new LocalVariableTable(code.getMaxLocals(), cpool, attr); |
|
|
|
lvt = new LocalVariableTable(code.getMaxLocals(), cpool, attr); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
initParams(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int paramCount = method.getParamCount(); |
|
|
|
public void initParams() { |
|
|
|
|
|
|
|
Type[] paramTypes = method.getType().getParameterTypes(); |
|
|
|
|
|
|
|
int paramCount = (method.isStatic() ? 0 : 1) + paramTypes.length; |
|
|
|
param = new LocalInfo[paramCount]; |
|
|
|
param = new LocalInfo[paramCount]; |
|
|
|
for (int i=0; i<paramCount; i++) |
|
|
|
int offset = 0; |
|
|
|
param[i] = getLocalInfo(0, i); |
|
|
|
int slot = 0; |
|
|
|
|
|
|
|
if (!method.isStatic()) |
|
|
|
|
|
|
|
param[offset++] = getLocalInfo(0, slot++); |
|
|
|
|
|
|
|
for (int i=0; i < paramTypes.length; i++) { |
|
|
|
|
|
|
|
param[offset++] = getLocalInfo(0, slot); |
|
|
|
|
|
|
|
slot += paramTypes[i].stackSize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public BytecodeInfo getBytecodeInfo() { |
|
|
|
public BytecodeInfo getBytecodeInfo() { |
|
|
@ -93,7 +114,6 @@ public class CodeAnalyzer implements Analyzer { |
|
|
|
/* The adjacent analyzation relies on this */ |
|
|
|
/* The adjacent analyzation relies on this */ |
|
|
|
DeadCodeAnalysis.removeDeadCode(code); |
|
|
|
DeadCodeAnalysis.removeDeadCode(code); |
|
|
|
Handler[] handlers = code.getExceptionHandlers(); |
|
|
|
Handler[] handlers = code.getExceptionHandlers(); |
|
|
|
|
|
|
|
|
|
|
|
int returnCount; |
|
|
|
int returnCount; |
|
|
|
TransformExceptionHandlers excHandlers; |
|
|
|
TransformExceptionHandlers excHandlers; |
|
|
|
{ |
|
|
|
{ |
|
|
@ -104,7 +124,7 @@ public class CodeAnalyzer implements Analyzer { |
|
|
|
instr != null; instr = instr.nextByAddr) { |
|
|
|
instr != null; instr = instr.nextByAddr) { |
|
|
|
if (instr.prevByAddr == null |
|
|
|
if (instr.prevByAddr == null |
|
|
|
|| instr.prevByAddr.alwaysJumps |
|
|
|
|| instr.prevByAddr.alwaysJumps |
|
|
|
|| instr.preds.size() != 1) |
|
|
|
|| instr.preds != null) |
|
|
|
instr.tmpInfo = new FlowBlock |
|
|
|
instr.tmpInfo = new FlowBlock |
|
|
|
(this, instr.addr, instr.length); |
|
|
|
(this, instr.addr, instr.length); |
|
|
|
} |
|
|
|
} |
|
|
@ -186,6 +206,11 @@ public class CodeAnalyzer implements Analyzer { |
|
|
|
if (Decompiler.isVerbose) |
|
|
|
if (Decompiler.isVerbose) |
|
|
|
Decompiler.err.print('-'); |
|
|
|
Decompiler.err.print('-'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// TabbedPrintWriter writer = new TabbedPrintWriter(System.err);
|
|
|
|
|
|
|
|
// methodHeader.dumpSource(writer);
|
|
|
|
|
|
|
|
// } catch (java.io.IOException ex) {
|
|
|
|
|
|
|
|
// }
|
|
|
|
excHandlers.analyze(); |
|
|
|
excHandlers.analyze(); |
|
|
|
methodHeader.analyze(); |
|
|
|
methodHeader.analyze(); |
|
|
|
} |
|
|
|
} |
|
|
@ -249,8 +274,8 @@ public class CodeAnalyzer implements Analyzer { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public LocalInfo getParamInfo(int slot) { |
|
|
|
public LocalInfo getParamInfo(int nr) { |
|
|
|
return param[slot]; |
|
|
|
return param[nr]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void useClass(String clazz) |
|
|
|
public void useClass(String clazz) |
|
|
|