Allow 'catch' and 'finally' blocks to abort script execution.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
3715b1b53d
commit
075f707a0a
14
engine/vm.c
14
engine/vm.c
|
@ -8184,11 +8184,13 @@ static sxi32 VmThrowException(
|
||||||
ph7_exception_block *pCatch; /* Catch block to execute */
|
ph7_exception_block *pCatch; /* Catch block to execute */
|
||||||
ph7_exception **apException;
|
ph7_exception **apException;
|
||||||
ph7_exception *pException;
|
ph7_exception *pException;
|
||||||
sxi32 rc;
|
sxi32 rc, rcc, rcf;
|
||||||
/* Point to the stack of loaded exceptions */
|
/* Point to the stack of loaded exceptions */
|
||||||
apException = (ph7_exception **)SySetBasePtr(&pVm->aException);
|
apException = (ph7_exception **)SySetBasePtr(&pVm->aException);
|
||||||
pException = 0;
|
pException = 0;
|
||||||
pCatch = 0;
|
pCatch = 0;
|
||||||
|
rcc = SXRET_OK;
|
||||||
|
rcf = SXRET_OK;
|
||||||
if(SySetUsed(&pVm->aException) > 0) {
|
if(SySetUsed(&pVm->aException) > 0) {
|
||||||
ph7_exception_block *aCatch;
|
ph7_exception_block *aCatch;
|
||||||
ph7_class *pClass;
|
ph7_class *pClass;
|
||||||
|
@ -8236,21 +8238,21 @@ static sxi32 VmThrowException(
|
||||||
MemObjSetType(pObj, MEMOBJ_OBJ);
|
MemObjSetType(pObj, MEMOBJ_OBJ);
|
||||||
}
|
}
|
||||||
/* Execute the block */
|
/* Execute the block */
|
||||||
VmLocalExec(&(*pVm), &pCatch->sByteCode, 0);
|
rcc = VmLocalExec(&(*pVm), &pCatch->sByteCode, 0);
|
||||||
/* Leave the frame */
|
/* Leave the frame */
|
||||||
VmLeaveFrame(&(*pVm));
|
VmLeaveFrame(&(*pVm));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Execute the 'finally' block if available */
|
/* Execute the 'finally' block if available */
|
||||||
if(pException && SySetUsed(&pException->sFinally)) {
|
if(pException && SySetUsed(&pException->sFinally)) {
|
||||||
rc = VmExecFinallyBlock(&(*pVm), pException);
|
rcf = VmExecFinallyBlock(&(*pVm), pException);
|
||||||
/* Release the bytecode container */
|
/* Release the bytecode container */
|
||||||
SySetRelease(&pException->sFinally);
|
SySetRelease(&pException->sFinally);
|
||||||
}
|
}
|
||||||
/* No matching 'catch' block found */
|
/* No matching 'catch' block found */
|
||||||
if(pCatch == 0) {
|
if(pCatch == 0) {
|
||||||
rc = VmUncaughtException(&(*pVm), pThis);
|
rcc = VmUncaughtException(&(*pVm), pThis);
|
||||||
if(rc == SXRET_OK && pException) {
|
if(rcc == SXRET_OK && pException) {
|
||||||
VmFrame *pFrame = pVm->pFrame;
|
VmFrame *pFrame = pVm->pFrame;
|
||||||
while(pFrame->pParent && (pFrame->iFlags & VM_FRAME_EXCEPTION)) {
|
while(pFrame->pParent && (pFrame->iFlags & VM_FRAME_EXCEPTION)) {
|
||||||
/* Safely ignore the exception frame */
|
/* Safely ignore the exception frame */
|
||||||
|
@ -8265,7 +8267,7 @@ static sxi32 VmThrowException(
|
||||||
/* TICKET 1433-60: Do not release the 'pException' pointer since it may
|
/* TICKET 1433-60: Do not release the 'pException' pointer since it may
|
||||||
* be used again if a 'goto' statement is executed.
|
* be used again if a 'goto' statement is executed.
|
||||||
*/
|
*/
|
||||||
return rc;
|
return rcc | rcf;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Section:
|
* Section:
|
||||||
|
|
Loading…
Reference in New Issue