Executor work

This commit is contained in:
Adam
2015-01-26 00:40:54 -05:00
parent a998491133
commit 55dca4fa9b
148 changed files with 512 additions and 194 deletions

View File

@@ -115,6 +115,19 @@ public class ClassFile
return null; return null;
} }
public Method findMethod(String name)
{
Method m = methods.findMethod(name);
if (m != null)
return m;
ClassFile parent = getParent();
if (parent != null)
return parent.findMethod(name);
return null;
}
public void buildClassGraph() public void buildClassGraph()
{ {

View File

@@ -1,5 +1,7 @@
package info.sigterm.deob; package info.sigterm.deob;
import info.sigterm.deob.execution.Execution;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -24,8 +26,20 @@ public class Deob
InputStream is = jar.getInputStream(entry); InputStream is = jar.getInputStream(entry);
group.addClass(entry.getName(), new DataInputStream(is)); group.addClass(entry.getName(), new DataInputStream(is));
} }
jar.close();
group.buildClassGraph(); group.buildClassGraph();
group.buildInstructionGraph(); group.buildInstructionGraph();
execute(group);
}
private static void execute(ClassGroup group) throws IOException
{
ClassFile cf = group.findClass("client");
Method method = cf.findMethod("init");
Execution e = new Execution(group);
e.run(cf, method);
} }
} }

View File

@@ -37,6 +37,14 @@ public class Methods
return m; return m;
return null; return null;
} }
public Method findMethod(String name)
{
for (Method m : methods)
if (m.getName().equals(name))
return m;
return null;
}
public void buildInstructionGraph() public void buildInstructionGraph()
{ {

View File

@@ -31,7 +31,7 @@ public class Code extends Attribute
public int getMaxStack() public int getMaxStack()
{ {
return getMaxStack(); return maxStack;
} }
public int getMaxLocals() public int getMaxLocals()

View File

@@ -174,12 +174,12 @@ public enum InstructionType
GOTO(0xa7, "goto", Goto.class), GOTO(0xa7, "goto", Goto.class),
TABLESWITCH(0xaa, "tableswitch", TableSwitch.class), TABLESWITCH(0xaa, "tableswitch", TableSwitch.class),
LOOKUPSWITCH(0xab, "lookupswitch", LookupSwitch.class), LOOKUPSWITCH(0xab, "lookupswitch", LookupSwitch.class),
IRETURN(0xac, "ireturn", Instruction.class), IRETURN(0xac, "ireturn", Return.class),
LRETURN(0xad, "lreturn", Instruction.class), LRETURN(0xad, "lreturn", Return.class),
FRETURN(0xae, "freturn", Instruction.class), FRETURN(0xae, "freturn", Return.class),
DRETURN(0xaf, "dreturn", Instruction.class), DRETURN(0xaf, "dreturn", Return.class),
ARETURN(0xb0, "areturn", Instruction.class), ARETURN(0xb0, "areturn", Return.class),
RETURN(0xb1, "return", Instruction.class), RETURN(0xb1, "return", VReturn.class),
GETSTATIC(0xb2, "getstatic", GetStatic.class), GETSTATIC(0xb2, "getstatic", GetStatic.class),
PUTSTATIC(0xb3, "putstatic", PutStatic.class), PUTSTATIC(0xb3, "putstatic", PutStatic.class),
GETFIELD(0xb4, "getfield", GetField.class), GETFIELD(0xb4, "getfield", GetField.class),
@@ -192,7 +192,7 @@ public enum InstructionType
NEWARRAY(0xbc, "newarray", NewArray.class), NEWARRAY(0xbc, "newarray", NewArray.class),
ANEWARRAY(0xbd, "anewarray", ANewArray.class), ANEWARRAY(0xbd, "anewarray", ANewArray.class),
ARRAYLENGTH(0xbe, "arraylength", ArrayLength.class), ARRAYLENGTH(0xbe, "arraylength", ArrayLength.class),
ATHROW(0xbf, "athrow", Instruction.class), ATHROW(0xbf, "athrow", AThrow.class),
CHECKCAST(0xc0, "checkcast", CheckCast.class), CHECKCAST(0xc0, "checkcast", CheckCast.class),
INSTANCEOf(0xc1, "instanceof", InstanceOf.class), INSTANCEOf(0xc1, "instanceof", InstanceOf.class),
MONITORENTER(0xc2, "monitorenter", MonitorEnter.class), MONITORENTER(0xc2, "monitorenter", MonitorEnter.class),

View File

@@ -22,6 +22,6 @@ public class AALoad extends Instruction
int index = (int) stack.pop(); int index = (int) stack.pop();
ArrayInstance array = (ArrayInstance) stack.pop(); ArrayInstance array = (ArrayInstance) stack.pop();
stack.push(array.get(index)); stack.push(this, array.get(index));
} }
} }

View File

@@ -19,6 +19,6 @@ public class AConstNull extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(null); stack.push(this, null);
} }
} }

View File

@@ -25,6 +25,6 @@ public class ALoad extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Object obj = frame.getVariables().get(index); Object obj = frame.getVariables().get(index);
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -19,6 +19,6 @@ public class ALoad_0 extends Instruction
{ {
Object obj = frame.getVariables().get(0); Object obj = frame.getVariables().get(0);
assert obj != null; assert obj != null;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -18,7 +18,6 @@ public class ALoad_1 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Object obj = frame.getVariables().get(1); Object obj = frame.getVariables().get(1);
assert obj != null; frame.getStack().push(this, obj);
frame.getStack().push(obj);
} }
} }

View File

@@ -18,7 +18,6 @@ public class ALoad_2 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Object obj = frame.getVariables().get(2); Object obj = frame.getVariables().get(2);
assert obj != null; frame.getStack().push(this, obj);
frame.getStack().push(obj);
} }
} }

View File

@@ -19,6 +19,6 @@ public class ALoad_3 extends Instruction
{ {
Object obj = frame.getVariables().get(3); Object obj = frame.getVariables().get(3);
assert obj != null; assert obj != null;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -36,13 +36,13 @@ public class ANewArray extends Instruction
ClassFile cf = thisClass.getGroup().findClass(clazz.getName()); ClassFile cf = thisClass.getGroup().findClass(clazz.getName());
if (cf == null) if (cf == null)
{ {
frame.getStack().push(null); frame.getStack().push(this, null);
return; return;
} }
ClassInstance type = frame.getPath().getClassInstance(cf); ClassInstance type = frame.getPath().getClassInstance(cf);
ArrayInstance array = frame.getPath().createArray(type, count); ArrayInstance array = frame.getPath().createArray(type, count);
frame.getStack().push(array); frame.getStack().push(this, array);
} }
} }

View File

@@ -18,7 +18,6 @@ public class AStore_1 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Object obj = frame.getStack().pop(); Object obj = frame.getStack().pop();
assert obj != null;
frame.getVariables().set(1, obj); frame.getVariables().set(1, obj);
} }
} }

View File

@@ -18,7 +18,6 @@ public class AStore_2 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Object obj = frame.getStack().pop(); Object obj = frame.getStack().pop();
assert obj != null;
frame.getVariables().set(2, obj); frame.getVariables().set(2, obj);
} }
} }

View File

@@ -0,0 +1,24 @@
package info.sigterm.deob.attributes.code.instructions;
import info.sigterm.deob.attributes.code.Instruction;
import info.sigterm.deob.attributes.code.InstructionType;
import info.sigterm.deob.attributes.code.Instructions;
import info.sigterm.deob.execution.Frame;
import info.sigterm.deob.execution.ObjectInstance;
import java.io.IOException;
public class AThrow extends Instruction
{
public AThrow(Instructions instructions, InstructionType type, int pc) throws IOException
{
super(instructions, type, pc);
}
@Override
public void execute(Frame e)
{
ObjectInstance exception = (ObjectInstance) e.getStack().pop();
e.getPath().throwException(exception);
}
}

View File

@@ -3,6 +3,7 @@ package info.sigterm.deob.attributes.code.instructions;
import info.sigterm.deob.attributes.code.Instruction; import info.sigterm.deob.attributes.code.Instruction;
import info.sigterm.deob.attributes.code.InstructionType; import info.sigterm.deob.attributes.code.InstructionType;
import info.sigterm.deob.attributes.code.Instructions; import info.sigterm.deob.attributes.code.Instructions;
import info.sigterm.deob.execution.ArrayInstance;
import info.sigterm.deob.execution.Frame; import info.sigterm.deob.execution.Frame;
import java.io.IOException; import java.io.IOException;
@@ -17,7 +18,7 @@ public class ArrayLength extends Instruction
@Override @Override
public void execute(Frame frame) public void execute(Frame frame)
{ {
Object[] array = (Object[]) frame.getStack().pop(); ArrayInstance array = (ArrayInstance) frame.getStack().pop();
frame.getStack().push(array.length); frame.getStack().push(this, array.getLength());
} }
} }

View File

@@ -21,6 +21,6 @@ public class BALoad extends Instruction
int index = (int) stack.pop(); int index = (int) stack.pop();
boolean[] array = (boolean[]) stack.pop(); boolean[] array = (boolean[]) stack.pop();
stack.push(array[index]); stack.push(this, array[index]);
} }
} }

View File

@@ -24,6 +24,6 @@ public class BiPush extends Instruction
@Override @Override
public void execute(Frame frame) public void execute(Frame frame)
{ {
frame.getStack().push((int) b); frame.getStack().push(this, (int) b);
} }
} }

View File

@@ -21,6 +21,6 @@ public class CALoad extends Instruction
int index = (int) stack.pop(); int index = (int) stack.pop();
char[] array = (char[]) stack.pop(); char[] array = (char[]) stack.pop();
stack.push(array[index]); stack.push(this, array[index]);
} }
} }

View File

@@ -36,7 +36,7 @@ public class CheckCast extends Instruction
ObjectInstance obj = (ObjectInstance) e.getStack().pop(); ObjectInstance obj = (ObjectInstance) e.getStack().pop();
if (obj == null) if (obj == null)
{ {
e.getStack().push(null); e.getStack().push(this, null);
return; return;
} }
@@ -48,7 +48,7 @@ public class CheckCast extends Instruction
// XXX throw // XXX throw
} }
e.getStack().push(obj); e.getStack().push(this, obj);
} }
} }

View File

@@ -24,6 +24,6 @@ public class D2F extends Instruction
assert obj instanceof Double; assert obj instanceof Double;
Double d = (Double) obj; Double d = (Double) obj;
stack.push(d.floatValue()); stack.push(this, d.floatValue());
} }
} }

View File

@@ -24,6 +24,6 @@ public class D2I extends Instruction
assert obj instanceof Double; assert obj instanceof Double;
Double d = (Double) obj; Double d = (Double) obj;
stack.push(d.intValue()); stack.push(this, d.intValue());
} }
} }

View File

@@ -24,6 +24,6 @@ public class D2L extends Instruction
assert obj instanceof Double; assert obj instanceof Double;
Double d = (Double) obj; Double d = (Double) obj;
stack.push(d.longValue()); stack.push(this, d.longValue());
} }
} }

View File

@@ -21,6 +21,6 @@ public class DALoad extends Instruction
int index = (int) stack.pop(); int index = (int) stack.pop();
double[] array = (double[]) stack.pop(); double[] array = (double[]) stack.pop();
stack.push(array[index]); stack.push(this, array[index]);
} }
} }

View File

@@ -21,6 +21,6 @@ public class DAdd extends Instruction
Double two = (Double) stack.pop(); Double two = (Double) stack.pop();
Double one = (Double) stack.pop(); Double one = (Double) stack.pop();
stack.push(one + two); stack.push(this, one + two);
} }
} }

View File

@@ -24,12 +24,12 @@ public class DCmpG extends Instruction
Double two = (Double) stack.pop(); Double two = (Double) stack.pop();
if (one.isNaN() || two.isNaN()) if (one.isNaN() || two.isNaN())
stack.push(1); stack.push(this, 1);
else if (one > two) else if (one > two)
stack.push(1); stack.push(this, 1);
else if (one < two) else if (one < two)
stack.push(-1); stack.push(this, -1);
else else
stack.push(0); stack.push(this, 0);
} }
} }

View File

@@ -24,12 +24,12 @@ public class DCmpL extends Instruction
Double two = (Double) stack.pop(); Double two = (Double) stack.pop();
if (one.isNaN() || two.isNaN()) if (one.isNaN() || two.isNaN())
stack.push(-1); stack.push(this, -1);
else if (one > two) else if (one > two)
stack.push(1); stack.push(this, 1);
else if (one < two) else if (one < two)
stack.push(-1); stack.push(this, -1);
else else
stack.push(0); stack.push(this, 0);
} }
} }

View File

@@ -19,6 +19,6 @@ public class DConst_0 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(0d); stack.push(this, 0d);
} }
} }

View File

@@ -19,6 +19,6 @@ public class DConst_1 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(1d); stack.push(this, 1d);
} }
} }

View File

@@ -21,6 +21,6 @@ public class DDiv extends Instruction
Double two = (Double) stack.pop(); Double two = (Double) stack.pop();
Double one = (Double) stack.pop(); Double one = (Double) stack.pop();
stack.push(one / two); stack.push(this, one / two);
} }
} }

View File

@@ -25,6 +25,6 @@ public class DLoad extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
double d = (double) frame.getVariables().get(index); double d = (double) frame.getVariables().get(index);
frame.getStack().push(d); frame.getStack().push(this, d);
} }
} }

View File

@@ -19,6 +19,6 @@ public class DLoad_0 extends Instruction
{ {
Object obj = frame.getVariables().get(0); Object obj = frame.getVariables().get(0);
assert obj instanceof Double; assert obj instanceof Double;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -19,6 +19,6 @@ public class DLoad_1 extends Instruction
{ {
Object obj = frame.getVariables().get(1); Object obj = frame.getVariables().get(1);
assert obj instanceof Double; assert obj instanceof Double;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -19,6 +19,6 @@ public class DLoad_2 extends Instruction
{ {
Object obj = frame.getVariables().get(2); Object obj = frame.getVariables().get(2);
assert obj instanceof Double; assert obj instanceof Double;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -19,6 +19,6 @@ public class DLoad_3 extends Instruction
{ {
Object obj = frame.getVariables().get(3); Object obj = frame.getVariables().get(3);
assert obj instanceof Double; assert obj instanceof Double;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -21,6 +21,6 @@ public class DMul extends Instruction
Double two = (Double) stack.pop(); Double two = (Double) stack.pop();
Double one = (Double) stack.pop(); Double one = (Double) stack.pop();
stack.push(one * two); stack.push(this, one * two);
} }
} }

View File

@@ -19,6 +19,6 @@ public class DNeg extends Instruction
Stack stack = frame.getStack(); Stack stack = frame.getStack();
Double value = (Double) stack.pop(); Double value = (Double) stack.pop();
stack.push(-value); stack.push(this, -value);
} }
} }

View File

@@ -21,6 +21,6 @@ public class DRem extends Instruction
Double two = (Double) stack.pop(); Double two = (Double) stack.pop();
Double one = (Double) stack.pop(); Double one = (Double) stack.pop();
stack.push(one % two); stack.push(this, one % two);
} }
} }

View File

@@ -21,6 +21,6 @@ public class DSub extends Instruction
Double two = (Double) stack.pop(); Double two = (Double) stack.pop();
Double one = (Double) stack.pop(); Double one = (Double) stack.pop();
stack.push(one - two); stack.push(this, one - two);
} }
} }

View File

@@ -18,7 +18,7 @@ public class Dup extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Object obj = frame.getStack().pop(); Object obj = frame.getStack().pop();
frame.getStack().push(obj); frame.getStack().push(this, obj);
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -26,11 +26,11 @@ public class Dup2 extends Instruction
two = stack.pop(); two = stack.pop();
if (!(one instanceof Double) && !(one instanceof Long)) if (!(one instanceof Double) && !(one instanceof Long))
stack.push(two); stack.push(this, two);
stack.push(one); stack.push(this, one);
if (!(one instanceof Double) && !(one instanceof Long)) if (!(one instanceof Double) && !(one instanceof Long))
stack.push(two); stack.push(this, two);
stack.push(one); stack.push(this, one);
} }
} }

View File

@@ -27,13 +27,13 @@ public class Dup2_X1 extends Instruction
Object three = stack.pop(); Object three = stack.pop();
if (!(one instanceof Double) && !(one instanceof Long)) if (!(one instanceof Double) && !(one instanceof Long))
stack.push(two); stack.push(this, two);
stack.push(one); stack.push(this, one);
stack.push(three); stack.push(this, three);
if (!(one instanceof Double) && !(one instanceof Long)) if (!(one instanceof Double) && !(one instanceof Long))
stack.push(two); stack.push(this, two);
stack.push(one); stack.push(this, one);
} }
} }

View File

@@ -30,15 +30,15 @@ public class Dup2_X2 extends Instruction
four = stack.pop(); four = stack.pop();
if (!(one instanceof Double) && !(one instanceof Long)) if (!(one instanceof Double) && !(one instanceof Long))
stack.push(two); stack.push(this, two);
stack.push(one); stack.push(this, one);
if (!(three instanceof Double) && !(three instanceof Long)) if (!(three instanceof Double) && !(three instanceof Long))
stack.push(four); stack.push(this, four);
stack.push(three); stack.push(this, three);
if (!(one instanceof Double) && !(one instanceof Long)) if (!(one instanceof Double) && !(one instanceof Long))
stack.push(two); stack.push(this, two);
stack.push(one); stack.push(this, one);
} }
} }

View File

@@ -23,8 +23,8 @@ public class Dup_X1 extends Instruction
Object one = stack.pop(); Object one = stack.pop();
Object two = stack.pop(); Object two = stack.pop();
stack.push(one); stack.push(this, one);
stack.push(two); stack.push(this, two);
stack.push(one); stack.push(this, one);
} }
} }

View File

@@ -26,10 +26,10 @@ public class Dup_X2 extends Instruction
if (!(two instanceof Double) && !(two instanceof Long)) if (!(two instanceof Double) && !(two instanceof Long))
three = stack.pop(); three = stack.pop();
stack.push(one); stack.push(this, one);
if (!(two instanceof Double) && !(two instanceof Long)) if (!(two instanceof Double) && !(two instanceof Long))
stack.push(three); stack.push(this, three);
stack.push(two); stack.push(this, two);
stack.push(one); stack.push(this, one);
} }
} }

View File

@@ -24,6 +24,6 @@ public class F2D extends Instruction
assert obj instanceof Float; assert obj instanceof Float;
Float f = (Float) obj; Float f = (Float) obj;
stack.push(f.doubleValue()); stack.push(this, f.doubleValue());
} }
} }

View File

@@ -24,6 +24,6 @@ public class F2I extends Instruction
assert obj instanceof Float; assert obj instanceof Float;
Float f = (Float) obj; Float f = (Float) obj;
stack.push(f.intValue()); stack.push(this, f.intValue());
} }
} }

View File

@@ -24,6 +24,6 @@ public class F2L extends Instruction
assert obj instanceof Float; assert obj instanceof Float;
Float f = (Float) obj; Float f = (Float) obj;
stack.push(f.longValue()); stack.push(this, f.longValue());
} }
} }

View File

@@ -21,6 +21,6 @@ public class FALoad extends Instruction
int index = (int) stack.pop(); int index = (int) stack.pop();
float[] array = (float[]) stack.pop(); float[] array = (float[]) stack.pop();
stack.push(array[index]); stack.push(this, array[index]);
} }
} }

View File

@@ -21,6 +21,6 @@ public class FAdd extends Instruction
Float one = (Float) stack.pop(); Float one = (Float) stack.pop();
Float two = (Float) stack.pop(); Float two = (Float) stack.pop();
stack.push(one + two); stack.push(this, one + two);
} }
} }

View File

@@ -24,12 +24,12 @@ public class FCmpG extends Instruction
Float two = (Float) stack.pop(); Float two = (Float) stack.pop();
if (one.isNaN() || two.isNaN()) if (one.isNaN() || two.isNaN())
stack.push(1); stack.push(this, 1);
else if (one > two) else if (one > two)
stack.push(1); stack.push(this, 1);
else if (one < two) else if (one < two)
stack.push(-1); stack.push(this, -1);
else else
stack.push(0); stack.push(this, 0);
} }
} }

View File

@@ -24,12 +24,12 @@ public class FCmpL extends Instruction
Float two = (Float) stack.pop(); Float two = (Float) stack.pop();
if (one.isNaN() || two.isNaN()) if (one.isNaN() || two.isNaN())
stack.push(-1); stack.push(this, -1);
else if (one > two) else if (one > two)
stack.push(1); stack.push(this, 1);
else if (one < two) else if (one < two)
stack.push(-1); stack.push(this, -1);
else else
stack.push(0); stack.push(this, 0);
} }
} }

View File

@@ -19,6 +19,6 @@ public class FConst_0 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(0f); stack.push(this, 0f);
} }
} }

View File

@@ -19,6 +19,6 @@ public class FConst_1 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(1f); stack.push(this, 1f);
} }
} }

View File

@@ -19,6 +19,6 @@ public class FConst_2 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(2f); stack.push(this, 2f);
} }
} }

View File

@@ -21,6 +21,6 @@ public class FDiv extends Instruction
Float two = (Float) stack.pop(); Float two = (Float) stack.pop();
Float one = (Float) stack.pop(); Float one = (Float) stack.pop();
stack.push(one / two); stack.push(this, one / two);
} }
} }

View File

@@ -25,6 +25,6 @@ public class FLoad extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
float f = (float) frame.getVariables().get(index); float f = (float) frame.getVariables().get(index);
frame.getStack().push(f); frame.getStack().push(this, f);
} }
} }

View File

@@ -19,6 +19,6 @@ public class FLoad_0 extends Instruction
{ {
Object obj = frame.getVariables().get(0); Object obj = frame.getVariables().get(0);
assert obj instanceof Float; assert obj instanceof Float;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -19,6 +19,6 @@ public class FLoad_1 extends Instruction
{ {
Object obj = frame.getVariables().get(1); Object obj = frame.getVariables().get(1);
assert obj instanceof Float; assert obj instanceof Float;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -19,6 +19,6 @@ public class FLoad_2 extends Instruction
{ {
Object obj = frame.getVariables().get(2); Object obj = frame.getVariables().get(2);
assert obj instanceof Float; assert obj instanceof Float;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -19,6 +19,6 @@ public class FLoad_3 extends Instruction
{ {
Object obj = frame.getVariables().get(3); Object obj = frame.getVariables().get(3);
assert obj instanceof Float; assert obj instanceof Float;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -21,6 +21,6 @@ public class FMul extends Instruction
Float two = (Float) stack.pop(); Float two = (Float) stack.pop();
Float one = (Float) stack.pop(); Float one = (Float) stack.pop();
stack.push(one * two); stack.push(this, one * two);
} }
} }

View File

@@ -19,6 +19,6 @@ public class FNeg extends Instruction
Stack stack = frame.getStack(); Stack stack = frame.getStack();
Float value = (Float) stack.pop(); Float value = (Float) stack.pop();
stack.push(-value); stack.push(this, -value);
} }
} }

View File

@@ -21,6 +21,6 @@ public class FRem extends Instruction
Float two = (Float) stack.pop(); Float two = (Float) stack.pop();
Float one = (Float) stack.pop(); Float one = (Float) stack.pop();
stack.push(one % two); stack.push(this, one % two);
} }
} }

View File

@@ -21,6 +21,6 @@ public class FSub extends Instruction
Float two = (Float) stack.pop(); Float two = (Float) stack.pop();
Float one = (Float) stack.pop(); Float one = (Float) stack.pop();
stack.push(one - two); stack.push(this, one - two);
} }
} }

View File

@@ -39,7 +39,13 @@ public class GetField extends Instruction
NameAndType nat = entry.getNameAndType(); NameAndType nat = entry.getNameAndType();
if (object == null)
{
frame.getStack().push(this, null);
return;
}
FieldInstance field = object.getField(nat); FieldInstance field = object.getField(nat);
frame.getStack().push(field.getValue()); frame.getStack().push(this, field.getValue());
} }
} }

View File

@@ -43,7 +43,7 @@ public class GetStatic extends Instruction
if (cf == null) if (cf == null)
{ {
Object ovalue = nat.getStackObject(); Object ovalue = nat.getStackObject();
frame.getStack().push(ovalue); frame.getStack().push(this, ovalue);
return; return;
} }
@@ -51,7 +51,7 @@ public class GetStatic extends Instruction
StaticFieldInstance fi = ci.findStaticField(nat); StaticFieldInstance fi = ci.findStaticField(nat);
Object ovalue = fi.getValue(); Object ovalue = fi.getValue();
frame.getStack().push(ovalue); frame.getStack().push(this, ovalue);
} }
@Override @Override

View File

@@ -24,6 +24,6 @@ public class I2B extends Instruction
assert obj instanceof Integer; assert obj instanceof Integer;
Integer i = (Integer) obj; Integer i = (Integer) obj;
stack.push(i.byteValue()); stack.push(this, i.byteValue());
} }
} }

View File

@@ -24,6 +24,6 @@ public class I2C extends Instruction
assert obj instanceof Integer; assert obj instanceof Integer;
Integer i = (Integer) obj; Integer i = (Integer) obj;
stack.push((char) i.intValue()); stack.push(this, (char) i.intValue());
} }
} }

View File

@@ -24,6 +24,6 @@ public class I2D extends Instruction
assert obj instanceof Integer; assert obj instanceof Integer;
Integer i = (Integer) obj; Integer i = (Integer) obj;
stack.push(i.doubleValue()); stack.push(this, i.doubleValue());
} }
} }

View File

@@ -24,6 +24,6 @@ public class I2F extends Instruction
assert obj instanceof Integer; assert obj instanceof Integer;
Integer i = (Integer) obj; Integer i = (Integer) obj;
stack.push(i.floatValue()); stack.push(this, i.floatValue());
} }
} }

View File

@@ -24,6 +24,6 @@ public class I2L extends Instruction
assert obj instanceof Integer; assert obj instanceof Integer;
Integer i = (Integer) obj; Integer i = (Integer) obj;
stack.push(i.longValue()); stack.push(this, i.longValue());
} }
} }

View File

@@ -24,6 +24,6 @@ public class I2S extends Instruction
assert obj instanceof Integer; assert obj instanceof Integer;
Integer i = (Integer) obj; Integer i = (Integer) obj;
stack.push(i.shortValue()); stack.push(this, i.shortValue());
} }
} }

View File

@@ -21,6 +21,6 @@ public class IALoad extends Instruction
int index = (int) stack.pop(); int index = (int) stack.pop();
int[] array = (int[]) stack.pop(); int[] array = (int[]) stack.pop();
stack.push(array[index]); stack.push(this, array[index]);
} }
} }

View File

@@ -21,6 +21,6 @@ public class IAdd extends Instruction
Integer two = (Integer) stack.pop(); Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop(); Integer one = (Integer) stack.pop();
stack.push(one + two); stack.push(this, one + two);
} }
} }

View File

@@ -20,6 +20,6 @@ public class IAnd extends Instruction
Integer two = (Integer) stack.pop(); Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop(); Integer one = (Integer) stack.pop();
stack.push(one & two); stack.push(this, one & two);
} }
} }

View File

@@ -19,6 +19,6 @@ public class IConst_0 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(0); stack.push(this, 0);
} }
} }

View File

@@ -19,6 +19,6 @@ public class IConst_1 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(1); stack.push(this, 1);
} }
} }

View File

@@ -19,6 +19,6 @@ public class IConst_2 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(2); stack.push(this, 2);
} }
} }

View File

@@ -19,6 +19,6 @@ public class IConst_3 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(3); stack.push(this, 3);
} }
} }

View File

@@ -19,6 +19,6 @@ public class IConst_4 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(4); stack.push(this, 4);
} }
} }

View File

@@ -19,6 +19,6 @@ public class IConst_5 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(5); stack.push(this, 5);
} }
} }

View File

@@ -19,6 +19,6 @@ public class IConst_M1 extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
Stack stack = frame.getStack(); Stack stack = frame.getStack();
stack.push(-1); stack.push(this, -1);
} }
} }

View File

@@ -21,6 +21,6 @@ public class IDiv extends Instruction
Double two = (Double) stack.pop(); Double two = (Double) stack.pop();
Double one = (Double) stack.pop(); Double one = (Double) stack.pop();
stack.push(one / two); stack.push(this, one / two);
} }
} }

View File

@@ -25,6 +25,6 @@ public class ILoad extends Instruction
public void execute(Frame frame) public void execute(Frame frame)
{ {
int i = (int) frame.getVariables().get(index); int i = (int) frame.getVariables().get(index);
frame.getStack().push(i); frame.getStack().push(this, i);
} }
} }

View File

@@ -19,6 +19,6 @@ public class ILoad_0 extends Instruction
{ {
Object obj = frame.getVariables().get(0); Object obj = frame.getVariables().get(0);
assert obj instanceof Integer; assert obj instanceof Integer;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -19,6 +19,6 @@ public class ILoad_1 extends Instruction
{ {
Object obj = frame.getVariables().get(1); Object obj = frame.getVariables().get(1);
assert obj instanceof Integer; assert obj instanceof Integer;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -19,6 +19,6 @@ public class ILoad_2 extends Instruction
{ {
Object obj = frame.getVariables().get(2); Object obj = frame.getVariables().get(2);
assert obj instanceof Integer; assert obj instanceof Integer;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -19,6 +19,6 @@ public class ILoad_3 extends Instruction
{ {
Object obj = frame.getVariables().get(3); Object obj = frame.getVariables().get(3);
assert obj instanceof Integer; assert obj instanceof Integer;
frame.getStack().push(obj); frame.getStack().push(this, obj);
} }
} }

View File

@@ -21,6 +21,6 @@ public class IMul extends Instruction
Integer two = (Integer) stack.pop(); Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop(); Integer one = (Integer) stack.pop();
stack.push(one * two); stack.push(this, one * two);
} }
} }

View File

@@ -19,6 +19,6 @@ public class INeg extends Instruction
Stack stack = frame.getStack(); Stack stack = frame.getStack();
Integer value = (Integer) stack.pop(); Integer value = (Integer) stack.pop();
stack.push(-value); stack.push(this, -value);
} }
} }

View File

@@ -20,6 +20,6 @@ public class IOr extends Instruction
Integer two = (Integer) stack.pop(); Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop(); Integer one = (Integer) stack.pop();
stack.push(one | two); stack.push(this, one | two);
} }
} }

View File

@@ -21,6 +21,6 @@ public class IRem extends Instruction
Integer two = (Integer) stack.pop(); Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop(); Integer one = (Integer) stack.pop();
stack.push(one % two); stack.push(this, one % two);
} }
} }

View File

@@ -20,6 +20,6 @@ public class IShL extends Instruction
Integer two = (Integer) stack.pop(); Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop(); Integer one = (Integer) stack.pop();
stack.push(one << (two & 0x1F)); stack.push(this, one << (two & 0x1F));
} }
} }

View File

@@ -20,6 +20,6 @@ public class IShR extends Instruction
Integer two = (Integer) stack.pop(); Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop(); Integer one = (Integer) stack.pop();
stack.push(one >> (two & 0x1F)); stack.push(this, one >> (two & 0x1F));
} }
} }

View File

@@ -21,6 +21,6 @@ public class ISub extends Instruction
Integer two = (Integer) stack.pop(); Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop(); Integer one = (Integer) stack.pop();
stack.push(one - two); stack.push(this, one - two);
} }
} }

View File

@@ -20,6 +20,6 @@ public class IUShR extends Instruction
Integer two = (Integer) stack.pop(); Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop(); Integer one = (Integer) stack.pop();
stack.push(one >>> (two & 0x1F)); stack.push(this, one >>> (two & 0x1F));
} }
} }

View File

@@ -20,6 +20,6 @@ public class IXor extends Instruction
Integer two = (Integer) stack.pop(); Integer two = (Integer) stack.pop();
Integer one = (Integer) stack.pop(); Integer one = (Integer) stack.pop();
stack.push(one ^ two); stack.push(this, one ^ two);
} }
} }

View File

@@ -36,13 +36,13 @@ public class InstanceOf extends Instruction
ObjectInstanceBase obj = (ObjectInstanceBase) e.getStack().pop(); ObjectInstanceBase obj = (ObjectInstanceBase) e.getStack().pop();
if (obj == null) if (obj == null)
{ {
e.getStack().push(0); e.getStack().push(this, 0);
return; return;
} }
ClassFile otherClass = thisClass.getGroup().findClass(clazz.getName()); ClassFile otherClass = thisClass.getGroup().findClass(clazz.getName());
boolean instanceOf = obj.getType().getClassFile().instanceOf(otherClass); boolean instanceOf = obj.getType().getClassFile().instanceOf(otherClass);
e.getStack().push(instanceOf ? 1 : 0); e.getStack().push(this, instanceOf ? 1 : 0);
} }
} }

Some files were not shown because too many files have changed in this diff Show More