Now is a code transformer

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1014 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent ff684745d1
commit bf0d0cceb7
  1. 36
      jode/jode/obfuscator/LocalOptimizer.java

@ -57,7 +57,7 @@ import jode.GlobalOptions;
* are not only left by the ret instructions, but also "spontanously"
* (by not reading the return address again).
*/
public class LocalOptimizer implements Opcodes {
public class LocalOptimizer implements Opcodes, CodeTransformer {
/**
* This class keeps track of which locals must be the same, which
@ -183,7 +183,6 @@ public class LocalOptimizer implements Opcodes {
}
BytecodeInfo bc;
MethodIdentifier methodIdent;
InstrInfo firstInfo;
Stack changedInfos;
@ -193,9 +192,7 @@ public class LocalOptimizer implements Opcodes {
LocalInfo[] paramLocals;
public LocalOptimizer(MethodIdentifier methodIdent, BytecodeInfo bc) {
this.methodIdent = methodIdent;
this.bc = bc;
public LocalOptimizer() {
}
@ -289,14 +286,14 @@ public class LocalOptimizer implements Opcodes {
/* Initialize paramLocals */
{
int paramCount = methodIdent.info.isStatic() ? 0 : 1;
int paramCount = bc.getMethodInfo().isStatic() ? 0 : 1;
Type[] paramTypes =
Type.tMethod(methodIdent.getType()).getParameterTypes();
Type.tMethod(bc.getMethodInfo().getType()).getParameterTypes();
for (int i = paramTypes.length; i-- > 0;)
paramCount += paramTypes[i].stackSize();
paramLocals = new LocalInfo[paramCount];
int slot = 0;
if (!methodIdent.info.isStatic()) {
if (!bc.getMethodInfo().isStatic()) {
LocalInfo local = new LocalInfo();
if (lvt != null) {
LocalVariableInfo lvi = findLVTEntry(lvt, 0, 0);
@ -879,4 +876,27 @@ public class LocalOptimizer implements Opcodes {
}
GlobalOptions.err.println("-----------");
}
public void transformCode(BytecodeInfo bytecode) {
this.bc = bytecode;
calcLocalInfo();
if ((GlobalOptions.debuggingFlags
& GlobalOptions.DEBUG_LOCALS) != 0) {
GlobalOptions.err.println("Before Local Optimization: ");
dumpLocals();
}
stripLocals();
distributeLocals();
if ((GlobalOptions.debuggingFlags
& GlobalOptions.DEBUG_LOCALS) != 0) {
GlobalOptions.err.println("After Local Optimization: ");
dumpLocals();
}
firstInfo = null;
changedInfos = null;
instrInfos = null;
paramLocals = null;
}
}

Loading…
Cancel
Save