Skip to content

Commit d1c53ca

Browse files
committed
Fixed edge case where a deterministic primitive call is the first executed instruction
1 parent 8552d46 commit d1c53ca

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/main/kotlin/be/ugent/topl/mio/debugger/MultiverseDebugger.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ class MultiverseGraph(var rootNode: MultiverseNode = MultiverseNode(), var curre
2525
fun replaceNode(node: MultiverseNode, newNode: MultiverseNode) {
2626
if (node == rootNode) {
2727
rootNode = newNode
28-
return
28+
} else {
29+
node.parent!!.children.remove(node)
30+
node.parent!!.addChild(newNode)
2931
}
3032

31-
node.parent!!.children.remove(node)
32-
node.parent!!.addChild(newNode)
33-
3433
for (child in node.children) {
3534
newNode.addChild(child)
3635
}
@@ -305,7 +304,13 @@ class MultiverseDebugger(
305304
DeterministicPrimitiveNode(wasmBinary.metadata.primitive_fidx_mapping[checkpoint.fidx_called], checkpoint.args!!)
306305
}
307306

308-
graph.replaceNode(graph.currentNode.parent!!, newNode)
307+
if (graph.currentNode.parent != null) {
308+
graph.replaceNode(graph.currentNode.parent!!, newNode)
309+
} else {
310+
// Current node has no parent -> it is the root node!
311+
graph.currentNode = newNode
312+
graph.rootNode = newNode
313+
}
309314
}
310315

311316
graphUpdated()

0 commit comments

Comments
 (0)