Implement OP_JMPLFB & OP_JMPLFE VM instructions.
The build was successful. Details

This commit is contained in:
Rafal Kupiec 2019-04-16 12:46:58 +02:00
parent ef4f994e8b
commit ba8e9080ef
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 25 additions and 0 deletions

View File

@ -2182,6 +2182,23 @@ static sxi32 VmByteCodeExec(
VmPopOperand(&pTos, 1); VmPopOperand(&pTos, 1);
} }
break; break;
case PH7_OP_JMPLFB: {
VmFrame *pFrame;
/* Enter the jump loop frame */
rc = VmEnterFrame(&(*pVm), pVm->pFrame->pUserData, pVm->pFrame->pThis, &pFrame);
if(rc != SXRET_OK) {
PH7_VmMemoryError(&(*pVm));
}
pFrame->iFlags = VM_FRAME_LOOP;
break;
}
case PH7_OP_JMPLFE: {
/* Leave the jump loop frame */
if(pVm->pFrame->iFlags & VM_FRAME_LOOP) {
VmLeaveFrame(&(*pVm));
}
break;
}
/* /*
* NOOP: * * * * NOOP: * * *
* *
@ -5405,6 +5422,12 @@ static const char *VmInstrToString(sxi32 nOp) {
case PH7_OP_JMPNZ: case PH7_OP_JMPNZ:
zOp = "JMPNZ"; zOp = "JMPNZ";
break; break;
case PH7_OP_JMPLFB:
zOp = "JMPLFB";
break;
case PH7_OP_JMPLFE:
zOp = "JMPLFB";
break;
case PH7_OP_POP: case PH7_OP_POP:
zOp = "POP"; zOp = "POP";
break; break;

View File

@ -1399,6 +1399,8 @@ enum ph7_vm_op {
PH7_OP_JMP, /* Unconditional jump */ PH7_OP_JMP, /* Unconditional jump */
PH7_OP_JMPZ, /* Jump on zero (FALSE jump) */ PH7_OP_JMPZ, /* Jump on zero (FALSE jump) */
PH7_OP_JMPNZ, /* Jump on non-zero (TRUE jump) */ PH7_OP_JMPNZ, /* Jump on non-zero (TRUE jump) */
PH7_OP_JMPLFB, /* Jump loop frame begin */
PH7_OP_JMPLFE, /* Jump loop frame end */
PH7_OP_POP, /* Stack POP */ PH7_OP_POP, /* Stack POP */
PH7_OP_CVT_INT, /* Integer cast */ PH7_OP_CVT_INT, /* Integer cast */
PH7_OP_CVT_STR, /* String cast */ PH7_OP_CVT_STR, /* String cast */