Browse Source

[lonetix/bgp] Fix Bgp_VmDoBreak() logic for nested BLKs

master
Lorenzo Cogotti 9 months ago
parent
commit
207924beac
  1. 19
      lonetix/include/df/bgp/vmintrin.h

19
lonetix/include/df/bgp/vmintrin.h

@ -174,19 +174,28 @@ FORCE_INLINE void Bgp_VmDoLoadn(Bgpvm *vm)
}
/// Break out of current `BLK`.
FORCE_INLINE void Bgp_VmDoBreak(Bgpvm *vm)
INLINE void Bgp_VmDoBreak(Bgpvm *vm)
{
Bgpvmopc opc;
unsigned n = 1;
do
opc = BGP_VMOPC(vm->prog[vm->pc++]);
while (opc != BGP_VMOP_ENDBLK && opc != BGP_VMOP_END);
do {
opc = BGP_VMOPC(vm->prog[vm->pc]);
if (opc == BGP_VMOP_END) // shouldn't happen with decent bytecode...
break;
if (opc == BGP_VMOP_BLK)
n++;
if (opc == BGP_VMOP_ENDBLK)
n--;
vm->pc++;
} while (n > 0);
if (opc == BGP_VMOP_ENDBLK)
vm->nblk--;
}
/// Execute `CALL` of function `vm->funcs[idx]`.
FORCE_INLINE void Bgp_VmDoCall(Bgpvm *vm, Uint8 idx)
{

Loading…
Cancel
Save