various debugging-related fixes

This commit is contained in:
2025-05-22 14:19:53 +03:00
parent 892408d9dd
commit a4c09b6cd6
6 changed files with 329 additions and 324 deletions

View File

@@ -38,8 +38,10 @@ public class CompoundNode extends Node {
for (var i = 0; i < statements.size(); i++) { for (var i = 0; i < statements.size(); i++) {
var stm = statements.get(i); var stm = statements.get(i);
if (i != statements.size() - 1) stm.compile(target, false, BreakpointType.STEP_OVER); if (i != statements.size() - 1) stm.compileStatement(target, false, BreakpointType.STEP_OVER);
else stm.compile(target, polluted = pollute, BreakpointType.STEP_OVER); else stm.compileStatement(target, polluted = pollute, BreakpointType.STEP_OVER);
target.setDebug(type);
} }
if (!polluted && pollute) { if (!polluted && pollute) {

View File

@@ -9,9 +9,14 @@ public abstract class Node {
public void resolve(CompileResult target) {} public void resolve(CompileResult target) {}
public void compile(CompileResult target, boolean pollute, BreakpointType type) { public void compile(CompileResult target, boolean pollute, BreakpointType type) {
compileStatement(target, pollute, type);
}
public void compileStatement(CompileResult target, boolean pollute, BreakpointType type) {
int start = target.size(); int start = target.size();
compile(target, pollute); compile(target, pollute);
if (target.size() != start) target.setLocationAndDebug(start, loc(), type); if (target.size() != start) {
target.setLocationAndDebug(start, loc(), type);
}
} }
public void compile(CompileResult target, boolean pollute) { public void compile(CompileResult target, boolean pollute) {
compile(target, pollute, BreakpointType.NONE); compile(target, pollute, BreakpointType.NONE);

View File

@@ -814,7 +814,6 @@ public class SimpleDebugger implements Debugger {
var cond = msg.params.string("condition", "").trim(); var cond = msg.params.string("condition", "").trim();
if (cond.equals("")) cond = null; if (cond.equals("")) cond = null;
if (cond != null) cond = "(" + cond + ")";
Pattern regex; Pattern regex;

View File

@@ -93,7 +93,7 @@ public interface DebugHandler {
} }
public default FunctionMap getMapOrEmpty(Environment env, FunctionValue func) { public default FunctionMap getMapOrEmpty(Environment env, FunctionValue func) {
if (func instanceof CodeFunction codeFunc) return getMapOrEmpty(env, codeFunc.body); if (func instanceof CodeFunction codeFunc) return getMapOrEmpty(env, codeFunc.body);
else return null; else return FunctionMap.EMPTY;
} }
public static DebugHandler get(Environment exts) { public static DebugHandler get(Environment exts) {

View File

@@ -195,7 +195,6 @@ public abstract class ArrayLikeValue extends ObjectValue {
res.add(" " + line); res.add(" " + line);
} }
} }
res.set(res.size() - 1, res.getLast().substring(0, res.getLast().length() - 1));
res.add("]"); res.add("]");
return res; return res;