vm: check for fault flag first in Run()
Switch cases are evaluated sequentially and the fault case is top-priority to handle.
This commit is contained in:
parent
705c7f106f
commit
0c963875af
1 changed files with 3 additions and 3 deletions
|
@ -225,6 +225,9 @@ func (v *VM) Run() {
|
||||||
v.state = noneState
|
v.state = noneState
|
||||||
for {
|
for {
|
||||||
switch {
|
switch {
|
||||||
|
case v.state.HasFlag(faultState):
|
||||||
|
fmt.Println("FAULT")
|
||||||
|
return
|
||||||
case v.state.HasFlag(haltState):
|
case v.state.HasFlag(haltState):
|
||||||
if !v.mute {
|
if !v.mute {
|
||||||
fmt.Println(v.Stack("estack"))
|
fmt.Println(v.Stack("estack"))
|
||||||
|
@ -235,9 +238,6 @@ func (v *VM) Run() {
|
||||||
i, op := ctx.CurrInstr()
|
i, op := ctx.CurrInstr()
|
||||||
fmt.Printf("at breakpoint %d (%s)\n", i, op.String())
|
fmt.Printf("at breakpoint %d (%s)\n", i, op.String())
|
||||||
return
|
return
|
||||||
case v.state.HasFlag(faultState):
|
|
||||||
fmt.Println("FAULT")
|
|
||||||
return
|
|
||||||
case v.state == noneState:
|
case v.state == noneState:
|
||||||
v.Step()
|
v.Step()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue