From a1bb5bdba60b72d8bf45dd28587c0872646a6635 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Wed, 25 Dec 2024 02:52:10 +0200 Subject: [PATCH] separate the call stack from the debug context --- .../topchetoeu/jscript/runtime/debug/DebugContext.java | 9 ++------- .../topchetoeu/jscript/runtime/debug/DebugHandler.java | 7 ++----- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main/java/me/topchetoeu/jscript/runtime/debug/DebugContext.java b/src/main/java/me/topchetoeu/jscript/runtime/debug/DebugContext.java index e9255a8..0431cff 100644 --- a/src/main/java/me/topchetoeu/jscript/runtime/debug/DebugContext.java +++ b/src/main/java/me/topchetoeu/jscript/runtime/debug/DebugContext.java @@ -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 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; } diff --git a/src/main/java/me/topchetoeu/jscript/runtime/debug/DebugHandler.java b/src/main/java/me/topchetoeu/jscript/runtime/debug/DebugHandler.java index 28afcc7..26d26b1 100644 --- a/src/main/java/me/topchetoeu/jscript/runtime/debug/DebugHandler.java +++ b/src/main/java/me/topchetoeu/jscript/runtime/debug/DebugHandler.java @@ -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 getStackFrame(); }