Closed codeh2o closed 2 years ago
Excellent question. There's a stub for 'debugger' here: https://github.com/NeilFraser/JS-Interpreter/blob/master/interpreter.js#L3865
So what I'd do is create a global (or a new property on Interpreter):
var debugStarted = false;
Then override the debug step:
Interpreter.prototype['stepDebuggerStatement'] = function(stack, state, node) {
debugStarted = true;
stack.pop();
};
And write a new run function:
function runToDebug () {
while (!debugStarted && myInterpreter.step()) {}
debugStarted = false;
}
This will make 'runToDebug' stop when 'debugger' is reached. Upon which one can either step, or run some more.
I hope the program can run and pause at the line of the debugger. not one step by step.
How can I do that?