refactor: remove unused instructions
This commit is contained in:
parent
60bbaaccd4
commit
8cffcff7db
@ -34,7 +34,6 @@ public class Instruction {
|
|||||||
LOAD_REGEX,
|
LOAD_REGEX,
|
||||||
|
|
||||||
DUP,
|
DUP,
|
||||||
MOVE,
|
|
||||||
|
|
||||||
STORE_VAR,
|
STORE_VAR,
|
||||||
STORE_MEMBER,
|
STORE_MEMBER,
|
||||||
@ -46,46 +45,6 @@ public class Instruction {
|
|||||||
|
|
||||||
TYPEOF,
|
TYPEOF,
|
||||||
OPERATION;
|
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 {
|
public static enum BreakpointType {
|
||||||
NONE,
|
NONE,
|
||||||
@ -240,13 +199,10 @@ public class Instruction {
|
|||||||
return new Instruction(loc, Type.LOAD_ARR, count);
|
return new Instruction(loc, Type.LOAD_ARR, count);
|
||||||
}
|
}
|
||||||
public static Instruction dup(Location loc) {
|
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) {
|
public static Instruction dup(Location loc, int count) {
|
||||||
return new Instruction(loc, Type.DUP, offset, count);
|
return new Instruction(loc, Type.DUP, count);
|
||||||
}
|
|
||||||
public static Instruction move(Location loc, int count, int offset) {
|
|
||||||
return new Instruction(loc, Type.MOVE, offset, count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Instruction storeSelfFunc(Location loc, int i) {
|
public static Instruction storeSelfFunc(Location loc, int i) {
|
||||||
|
@ -19,7 +19,7 @@ public class IndexAssignStatement extends Statement {
|
|||||||
if (operation != null) {
|
if (operation != null) {
|
||||||
object.compile(target, scope, true);
|
object.compile(target, scope, true);
|
||||||
index.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()));
|
target.add(Instruction.loadMember(loc()));
|
||||||
value.compile(target, scope, true);
|
value.compile(target, scope, true);
|
||||||
|
@ -119,27 +119,15 @@ public class Runners {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Object execDup(Context ctx, Instruction instr, CodeFrame frame) {
|
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++) {
|
for (var i = 0; i < count; i++) {
|
||||||
frame.push(ctx, frame.peek(offset + count - 1));
|
frame.push(ctx, frame.peek(count - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.codePtr++;
|
frame.codePtr++;
|
||||||
return NO_RETURN;
|
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) {
|
public static Object execLoadUndefined(Context ctx, Instruction instr, CodeFrame frame) {
|
||||||
frame.push(ctx, null);
|
frame.push(ctx, null);
|
||||||
frame.codePtr++;
|
frame.codePtr++;
|
||||||
@ -329,7 +317,6 @@ public class Runners {
|
|||||||
case TRY_END: return execTryEnd(ctx, instr, frame);
|
case TRY_END: return execTryEnd(ctx, instr, frame);
|
||||||
|
|
||||||
case DUP: return execDup(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_VALUE: return execLoadValue(ctx, instr, frame);
|
||||||
case LOAD_VAR: return execLoadVar(ctx, instr, frame);
|
case LOAD_VAR: return execLoadVar(ctx, instr, frame);
|
||||||
case LOAD_OBJ: return execLoadObj(ctx, instr, frame);
|
case LOAD_OBJ: return execLoadObj(ctx, instr, frame);
|
||||||
|
Loading…
Reference in New Issue
Block a user