Add support for source mappings #10

Merged
TopchetoEU merged 22 commits from TopchetoEU/mapping into master 2023-12-18 20:42:38 +00:00
4 changed files with 6 additions and 63 deletions
Showing only changes of commit 8cffcff7db - Show all commits

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File