shift-interpreter
Version:
Shift-interpreter is an experimental JavaScript meta-interpreter useful for reverse engineering and analysis. One notable difference from other projects is that shift-interpreter retains state over an entire script but can be fed expressions and statement
32 lines • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.InstructionBuffer = exports.Instruction = exports.InstructionBufferEventName = void 0;
var InstructionBufferEventName;
(function (InstructionBufferEventName) {
InstructionBufferEventName["REQUEST_EXECUTION"] = "requestExecution";
InstructionBufferEventName["HALT"] = "halt";
InstructionBufferEventName["CONTINUE"] = "continue";
})(InstructionBufferEventName = exports.InstructionBufferEventName || (exports.InstructionBufferEventName = {}));
class Instruction {
constructor(node, id) {
this.node = node;
this.id = id;
}
}
exports.Instruction = Instruction;
class InstructionBuffer {
constructor() {
this.buffer = [];
this.numInstructions = 0;
}
add(node) {
const instruction = new Instruction(node, this.numInstructions++);
this.buffer.push(instruction);
return instruction;
}
nextInstruction() {
return this.buffer.shift();
}
}
exports.InstructionBuffer = InstructionBuffer;
//# sourceMappingURL=instruction-buffer.js.map