Typehinting merge #50
@ -1438,26 +1438,15 @@ static sxi32 PH7_CompileContinue(ph7_gen_state *pGen) {
|
|||||||
pGen->pIn++;
|
pGen->pIn++;
|
||||||
/* Point to the target loop */
|
/* Point to the target loop */
|
||||||
pLoop = PH7_GenStateFetchBlock(pGen->pCurrent, GEN_BLOCK_LOOP, 0);
|
pLoop = PH7_GenStateFetchBlock(pGen->pCurrent, GEN_BLOCK_LOOP, 0);
|
||||||
if(pLoop == 0) {
|
if(pLoop == 0 || pLoop->iFlags & GEN_BLOCK_SWITCH) {
|
||||||
/* Illegal continue */
|
/* Illegal continue */
|
||||||
rc = PH7_GenCompileError(pGen, E_ERROR, nLine, "A 'continue' statement may only be used within a loop or switch");
|
rc = PH7_GenCompileError(pGen, E_ERROR, nLine, "A 'continue' statement may only be used within a loop");
|
||||||
if(rc == SXERR_ABORT) {
|
if(rc == SXERR_ABORT) {
|
||||||
/* Error count limit reached,abort immediately */
|
/* Error count limit reached,abort immediately */
|
||||||
return SXERR_ABORT;
|
return SXERR_ABORT;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sxu32 nInstrIdx = 0;
|
sxu32 nInstrIdx = 0;
|
||||||
if(pLoop->iFlags & GEN_BLOCK_SWITCH) {
|
|
||||||
/*
|
|
||||||
* Note that unlike some other languages, the continue statement applies to switch
|
|
||||||
* and acts similar to break. If you have a switch inside a loop and wish to continue
|
|
||||||
* to the next iteration of the outer loop, use continue 2.
|
|
||||||
*/
|
|
||||||
rc = PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JMP, 0, 0, 0, &nInstrIdx);
|
|
||||||
if(rc == SXRET_OK) {
|
|
||||||
PH7_GenStateNewJumpFixup(pLoop, PH7_OP_JMP, nInstrIdx);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(!pLoop->bPostContinue) {
|
if(!pLoop->bPostContinue) {
|
||||||
/* Emit the OP_JMPLFE instruction to leave the loop frame */
|
/* Emit the OP_JMPLFE instruction to leave the loop frame */
|
||||||
PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_JMPLFE, 0, 0, 0, 0);
|
PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_JMPLFE, 0, 0, 0, 0);
|
||||||
@ -1471,7 +1460,6 @@ static sxi32 PH7_CompileContinue(ph7_gen_state *pGen) {
|
|||||||
SySetPut(&pLoop->aPostContFix, (const void *)&sJumpFix);
|
SySetPut(&pLoop->aPostContFix, (const void *)&sJumpFix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_SEMI) == 0) {
|
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_SEMI) == 0) {
|
||||||
/* Not so fatal,emit a warning only */
|
/* Not so fatal,emit a warning only */
|
||||||
PH7_GenCompileError(&(*pGen), E_ERROR, pGen->pIn->nLine, "Expected semi-colon ';' after 'continue' statement");
|
PH7_GenCompileError(&(*pGen), E_ERROR, pGen->pIn->nLine, "Expected semi-colon ';' after 'continue' statement");
|
||||||
|
Loading…
Reference in New Issue
Block a user