Skip to content

Commit b8fefed

Browse files
committed
Fixed edge case where a deterministic primitive call is the first executed instruction
1 parent ba4dc62 commit b8fefed

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
@@ -24,12 +24,11 @@ class MultiverseGraph(var rootNode: MultiverseNode = MultiverseNode(), var curre
2424
fun replaceNode(node: MultiverseNode, newNode: MultiverseNode) {
2525
if (node == rootNode) {
2626
rootNode = newNode
27-
return
27+
} else {
28+
node.parent!!.children.remove(node)
29+
node.parent!!.addChild(newNode)
2830
}
2931

30-
node.parent!!.children.remove(node)
31-
node.parent!!.addChild(newNode)
32-
3332
for (child in node.children) {
3433
newNode.addChild(child)
3534
}
@@ -310,7 +309,13 @@ class MultiverseDebugger(
310309
DeterministicPrimitiveNode(wasmBinary.metadata.primitive_fidx_mapping[checkpoint.fidx_called], checkpoint.args!!)
311310
}
312311

313-
graph.replaceNode(graph.currentNode.parent!!, newNode)
312+
if (graph.currentNode.parent != null) {
313+
graph.replaceNode(graph.currentNode.parent!!, newNode)
314+
} else {
315+
// Current node has no parent -> it is the root node!
316+
graph.currentNode = newNode
317+
graph.rootNode = newNode
318+
}
314319
}
315320

316321
graphUpdated()

0 commit comments

Comments
 (0)