separate the call stack from the debug context
This commit is contained in:
parent
c699102e56
commit
a1bb5bdba6
@ -1,8 +1,6 @@
|
|||||||
package me.topchetoeu.jscript.runtime.debug;
|
package me.topchetoeu.jscript.runtime.debug;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.FunctionBody;
|
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.common.parsing.Filename;
|
||||||
import me.topchetoeu.jscript.runtime.Frame;
|
import me.topchetoeu.jscript.runtime.Frame;
|
||||||
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
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.CodeFunction;
|
||||||
import me.topchetoeu.jscript.runtime.values.functions.FunctionValue;
|
import me.topchetoeu.jscript.runtime.values.functions.FunctionValue;
|
||||||
|
|
||||||
@ -68,10 +67,6 @@ public class DebugContext {
|
|||||||
if (maps == null || !(func instanceof CodeFunction)) return FunctionMap.EMPTY;
|
if (maps == null || !(func instanceof CodeFunction)) return FunctionMap.EMPTY;
|
||||||
return getMapOrEmpty(((CodeFunction)func).body);
|
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) {
|
public void onFramePop(Environment env, Frame frame) {
|
||||||
if (debugger != null) debugger.onFramePop(env, frame);
|
if (debugger != null) debugger.onFramePop(env, frame);
|
||||||
@ -80,7 +75,7 @@ public class DebugContext {
|
|||||||
if (debugger != null) debugger.onFramePush(env, frame);
|
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);
|
if (debugger != null) return debugger.onInstruction(env, frame, instruction, returnVal, error, caught);
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package me.topchetoeu.jscript.runtime.debug;
|
package me.topchetoeu.jscript.runtime.debug;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import me.topchetoeu.jscript.common.FunctionBody;
|
import me.topchetoeu.jscript.common.FunctionBody;
|
||||||
import me.topchetoeu.jscript.common.Instruction;
|
import me.topchetoeu.jscript.common.Instruction;
|
||||||
import me.topchetoeu.jscript.common.environment.Environment;
|
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.common.parsing.Filename;
|
||||||
import me.topchetoeu.jscript.runtime.Frame;
|
import me.topchetoeu.jscript.runtime.Frame;
|
||||||
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
import me.topchetoeu.jscript.runtime.exceptions.EngineException;
|
||||||
|
import me.topchetoeu.jscript.runtime.values.Value;
|
||||||
|
|
||||||
public interface DebugHandler {
|
public interface DebugHandler {
|
||||||
/**
|
/**
|
||||||
@ -38,7 +37,7 @@ public interface DebugHandler {
|
|||||||
* @param caught Whether or not the error has been caught
|
* @param caught Whether or not the error has been caught
|
||||||
* @return Whether or not the frame should restart (currently does nothing)
|
* @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.
|
* 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
|
* @param frame The code frame which was popped out
|
||||||
*/
|
*/
|
||||||
void onFramePop(Environment env, Frame frame);
|
void onFramePop(Environment env, Frame frame);
|
||||||
|
|
||||||
List<Frame> getStackFrame();
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user