separate the call stack from the debug context

This commit is contained in:
TopchetoEU 2024-12-25 02:52:10 +02:00
parent c699102e56
commit a1bb5bdba6
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4
2 changed files with 4 additions and 12 deletions

View File

@ -1,8 +1,6 @@
package me.topchetoeu.jscript.runtime.debug;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.WeakHashMap;
import me.topchetoeu.jscript.common.FunctionBody;
@ -13,6 +11,7 @@ import me.topchetoeu.jscript.common.mapping.FunctionMap;
import me.topchetoeu.jscript.common.parsing.Filename;
import me.topchetoeu.jscript.runtime.Frame;
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
import me.topchetoeu.jscript.runtime.values.Value;
import me.topchetoeu.jscript.runtime.values.functions.CodeFunction;
import me.topchetoeu.jscript.runtime.values.functions.FunctionValue;
@ -68,10 +67,6 @@ public class DebugContext {
if (maps == null || !(func instanceof CodeFunction)) return FunctionMap.EMPTY;
return getMapOrEmpty(((CodeFunction)func).body);
}
public List<Frame> getStackFrames() {
if (debugger == null) return Arrays.asList();
return this.debugger.getStackFrame();
}
public void onFramePop(Environment env, Frame frame) {
if (debugger != null) debugger.onFramePop(env, frame);
@ -80,7 +75,7 @@ public class DebugContext {
if (debugger != null) debugger.onFramePush(env, frame);
}
public boolean onInstruction(Environment env, Frame frame, Instruction instruction, Object returnVal, EngineException error, boolean caught) {
public boolean onInstruction(Environment env, Frame frame, Instruction instruction, Value returnVal, EngineException error, boolean caught) {
if (debugger != null) return debugger.onInstruction(env, frame, instruction, returnVal, error, caught);
else return false;
}

View File

@ -1,7 +1,5 @@
package me.topchetoeu.jscript.runtime.debug;
import java.util.List;
import me.topchetoeu.jscript.common.FunctionBody;
import me.topchetoeu.jscript.common.Instruction;
import me.topchetoeu.jscript.common.environment.Environment;
@ -9,6 +7,7 @@ import me.topchetoeu.jscript.common.mapping.FunctionMap;
import me.topchetoeu.jscript.common.parsing.Filename;
import me.topchetoeu.jscript.runtime.Frame;
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
import me.topchetoeu.jscript.runtime.values.Value;
public interface DebugHandler {
/**
@ -38,7 +37,7 @@ public interface DebugHandler {
* @param caught Whether or not the error has been caught
* @return Whether or not the frame should restart (currently does nothing)
*/
boolean onInstruction(Environment env, Frame frame, Instruction instruction, Object returnVal, EngineException error, boolean caught);
boolean onInstruction(Environment env, Frame frame, Instruction instruction, Value returnVal, EngineException error, boolean caught);
/**
* Called immediatly before a frame has been pushed on the frame stack.
@ -54,6 +53,4 @@ public interface DebugHandler {
* @param frame The code frame which was popped out
*/
void onFramePop(Environment env, Frame frame);
List<Frame> getStackFrame();
}