mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-09 00:14:10 -08:00
Fix bugs in debugger
This commit is contained in:
parent
2095e52dc2
commit
a8f1940df3
|
@ -23,6 +23,7 @@ import com.carrotsearch.hppc.ObjectIntHashMap;
|
||||||
import com.carrotsearch.hppc.ObjectIntMap;
|
import com.carrotsearch.hppc.ObjectIntMap;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.BitSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -59,7 +60,11 @@ public final class LocationGraphBuilder {
|
||||||
Visitor visitor = new Visitor();
|
Visitor visitor = new Visitor();
|
||||||
node.acceptVisitor(visitor);
|
node.acceptVisitor(visitor);
|
||||||
Graph graph = visitor.builder.build();
|
Graph graph = visitor.builder.build();
|
||||||
TextLocation[][] locations = propagate(visitor.locations.toArray(new TextLocation[0]), graph);
|
for (int terminal : visitor.nodes) {
|
||||||
|
visitor.terminalNodes.set(terminal);
|
||||||
|
}
|
||||||
|
TextLocation[][] locations = propagate(visitor.locations.toArray(new TextLocation[0]), graph,
|
||||||
|
visitor.terminalNodes);
|
||||||
|
|
||||||
Map<TextLocation, Set<TextLocation>> builder = new LinkedHashMap<>();
|
Map<TextLocation, Set<TextLocation>> builder = new LinkedHashMap<>();
|
||||||
for (int i = 0; i < graph.size(); ++i) {
|
for (int i = 0; i < graph.size(); ++i) {
|
||||||
|
@ -70,6 +75,11 @@ public final class LocationGraphBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (visitor.terminalNodes.get(i)) {
|
||||||
|
for (TextLocation loc : locations[i]) {
|
||||||
|
builder.computeIfAbsent(loc, k -> new LinkedHashSet<>()).add(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<TextLocation, TextLocation[]> result = new LinkedHashMap<>();
|
Map<TextLocation, TextLocation[]> result = new LinkedHashMap<>();
|
||||||
|
@ -79,7 +89,7 @@ public final class LocationGraphBuilder {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TextLocation[][] propagate(TextLocation[] locations, Graph graph) {
|
private static TextLocation[][] propagate(TextLocation[] locations, Graph graph, BitSet terminal) {
|
||||||
List<Set<TextLocation>> result = new ArrayList<>();
|
List<Set<TextLocation>> result = new ArrayList<>();
|
||||||
boolean[] stop = new boolean[graph.size()];
|
boolean[] stop = new boolean[graph.size()];
|
||||||
IntDeque queue = new IntArrayDeque();
|
IntDeque queue = new IntArrayDeque();
|
||||||
|
@ -117,6 +127,7 @@ public final class LocationGraphBuilder {
|
||||||
IdentifiedStatement defaultContinueTarget;
|
IdentifiedStatement defaultContinueTarget;
|
||||||
GraphBuilder builder = new GraphBuilder();
|
GraphBuilder builder = new GraphBuilder();
|
||||||
List<TextLocation> locations = new ArrayList<>();
|
List<TextLocation> locations = new ArrayList<>();
|
||||||
|
BitSet terminalNodes = new BitSet();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterVisit(Expr expr) {
|
protected void afterVisit(Expr expr) {
|
||||||
|
@ -265,6 +276,9 @@ public final class LocationGraphBuilder {
|
||||||
public void visit(ReturnStatement statement) {
|
public void visit(ReturnStatement statement) {
|
||||||
super.visit(statement);
|
super.visit(statement);
|
||||||
setLocation(statement.getLocation());
|
setLocation(statement.getLocation());
|
||||||
|
for (int node : nodes) {
|
||||||
|
terminalNodes.set(node);
|
||||||
|
}
|
||||||
nodes = EMPTY;
|
nodes = EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,7 @@ public class Debugger {
|
||||||
return jsStep(enterMethod);
|
return jsStep(enterMethod);
|
||||||
}
|
}
|
||||||
Set<JavaScriptLocation> successors = new HashSet<>();
|
Set<JavaScriptLocation> successors = new HashSet<>();
|
||||||
|
boolean first = true;
|
||||||
for (CallFrame frame : callStack) {
|
for (CallFrame frame : callStack) {
|
||||||
boolean exits;
|
boolean exits;
|
||||||
String script = frame.getOriginalLocation().getScript();
|
String script = frame.getOriginalLocation().getScript();
|
||||||
|
@ -129,7 +130,13 @@ public class Debugger {
|
||||||
if (!exits) {
|
if (!exits) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
enterMethod = true;
|
enterMethod = false;
|
||||||
|
if (!first && frame.getLocation() != null) {
|
||||||
|
for (GeneratedLocation location : debugInfo.getGeneratedLocations(frame.getLocation())) {
|
||||||
|
successors.add(new JavaScriptLocation(script, location.getLine(), location.getColumn()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Promise<Void>> jsBreakpointPromises = new ArrayList<>();
|
List<Promise<Void>> jsBreakpointPromises = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user