diff --git a/src/me/topchetoeu/jscript/compilation/Instruction.java b/src/me/topchetoeu/jscript/compilation/Instruction.java index 2d9c21d..e589f4f 100644 --- a/src/me/topchetoeu/jscript/compilation/Instruction.java +++ b/src/me/topchetoeu/jscript/compilation/Instruction.java @@ -34,7 +34,6 @@ public class Instruction { LOAD_REGEX, DUP, - MOVE, STORE_VAR, STORE_MEMBER, @@ -46,46 +45,6 @@ public class Instruction { TYPEOF, OPERATION; - // TYPEOF, - // INSTANCEOF(true), - // IN(true), - - // MULTIPLY(true), - // DIVIDE(true), - // MODULO(true), - // ADD(true), - // SUBTRACT(true), - - // USHIFT_RIGHT(true), - // SHIFT_RIGHT(true), - // SHIFT_LEFT(true), - - // GREATER(true), - // LESS(true), - // GREATER_EQUALS(true), - // LESS_EQUALS(true), - // LOOSE_EQUALS(true), - // LOOSE_NOT_EQUALS(true), - // EQUALS(true), - // NOT_EQUALS(true), - - // AND(true), - // OR(true), - // XOR(true), - - // NEG(true), - // POS(true), - // NOT(true), - // INVERSE(true); - - // final boolean isOperation; - - // private Type(boolean isOperation) { - // this.isOperation = isOperation; - // } - // private Type() { - // this(false); - // } } public static enum BreakpointType { NONE, @@ -240,13 +199,10 @@ public class Instruction { return new Instruction(loc, Type.LOAD_ARR, count); } public static Instruction dup(Location loc) { - return new Instruction(loc, Type.DUP, 0, 1); + return new Instruction(loc, Type.DUP, 1); } - public static Instruction dup(Location loc, int count, int offset) { - return new Instruction(loc, Type.DUP, offset, count); - } - public static Instruction move(Location loc, int count, int offset) { - return new Instruction(loc, Type.MOVE, offset, count); + public static Instruction dup(Location loc, int count) { + return new Instruction(loc, Type.DUP, count); } public static Instruction storeSelfFunc(Location loc, int i) { diff --git a/src/me/topchetoeu/jscript/compilation/values/IndexAssignStatement.java b/src/me/topchetoeu/jscript/compilation/values/IndexAssignStatement.java index a67251d..77cb68c 100644 --- a/src/me/topchetoeu/jscript/compilation/values/IndexAssignStatement.java +++ b/src/me/topchetoeu/jscript/compilation/values/IndexAssignStatement.java @@ -19,7 +19,7 @@ public class IndexAssignStatement extends Statement { if (operation != null) { object.compile(target, scope, true); index.compile(target, scope, true); - target.add(Instruction.dup(loc(), 2, 0)); + target.add(Instruction.dup(loc(), 2)); target.add(Instruction.loadMember(loc())); value.compile(target, scope, true); diff --git a/src/me/topchetoeu/jscript/engine/frame/Runners.java b/src/me/topchetoeu/jscript/engine/frame/Runners.java index 862ce83..f2564fb 100644 --- a/src/me/topchetoeu/jscript/engine/frame/Runners.java +++ b/src/me/topchetoeu/jscript/engine/frame/Runners.java @@ -119,27 +119,15 @@ public class Runners { } public static Object execDup(Context ctx, Instruction instr, CodeFrame frame) { - int offset = instr.get(0), count = instr.get(1); + int count = instr.get(0); for (var i = 0; i < count; i++) { - frame.push(ctx, frame.peek(offset + count - 1)); + frame.push(ctx, frame.peek(count - 1)); } frame.codePtr++; return NO_RETURN; } - public static Object execMove(Context ctx, Instruction instr, CodeFrame frame) { - int offset = instr.get(0), count = instr.get(1); - - var tmp = frame.take(offset); - var res = frame.take(count); - - for (var i = 0; i < offset; i++) frame.push(ctx, tmp[i]); - for (var i = 0; i < count; i++) frame.push(ctx, res[i]); - - frame.codePtr++; - return NO_RETURN; - } public static Object execLoadUndefined(Context ctx, Instruction instr, CodeFrame frame) { frame.push(ctx, null); frame.codePtr++; @@ -329,7 +317,6 @@ public class Runners { case TRY_END: return execTryEnd(ctx, instr, frame); case DUP: return execDup(ctx, instr, frame); - case MOVE: return execMove(ctx, instr, frame); case LOAD_VALUE: return execLoadValue(ctx, instr, frame); case LOAD_VAR: return execLoadVar(ctx, instr, frame); case LOAD_OBJ: return execLoadObj(ctx, instr, frame); diff --git a/undefined b/undefined deleted file mode 100644 index e69de29..0000000