Typehinting merge #50
@ -2335,16 +2335,16 @@ static sxi32 PH7_CompileIf(ph7_gen_state *pGen) {
|
|||||||
if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & PH7_TK_KEYWORD) == 0) {
|
if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & PH7_TK_KEYWORD) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Ensure that the keyword ID is 'else if' or 'else' */
|
/* Ensure that the keyword ID is 'else' */
|
||||||
nKeyID = (sxu32)SX_PTR_TO_INT(pGen->pIn->pUserData);
|
nKeyID = (sxu32)SX_PTR_TO_INT(pGen->pIn->pUserData);
|
||||||
if((nKeyID & (PH7_KEYWORD_ELSE | PH7_KEYWORD_ELIF)) == 0) {
|
if(nKeyID != PH7_KEYWORD_ELSE) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Emit the unconditional jump */
|
/* Emit the unconditional jump */
|
||||||
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JMP, 0, 0, 0, &nJumpIdx);
|
PH7_VmEmitInstr(pGen->pVm, 0, PH7_OP_JMP, 0, 0, 0, &nJumpIdx);
|
||||||
/* Save the instruction index so we can fix it later when the jump destination is resolved */
|
/* Save the instruction index so we can fix it later when the jump destination is resolved */
|
||||||
PH7_GenStateNewJumpFixup(pCondBlock, PH7_OP_JMP, nJumpIdx);
|
PH7_GenStateNewJumpFixup(pCondBlock, PH7_OP_JMP, nJumpIdx);
|
||||||
if(nKeyID & PH7_KEYWORD_ELSE) {
|
if(nKeyID == PH7_KEYWORD_ELSE) {
|
||||||
pToken = &pGen->pIn[1];
|
pToken = &pGen->pIn[1];
|
||||||
if(pToken >= pGen->pEnd || (pToken->nType & PH7_TK_KEYWORD) == 0 ||
|
if(pToken >= pGen->pEnd || (pToken->nType & PH7_TK_KEYWORD) == 0 ||
|
||||||
SX_PTR_TO_INT(pToken->pUserData) != PH7_KEYWORD_IF) {
|
SX_PTR_TO_INT(pToken->pUserData) != PH7_KEYWORD_IF) {
|
||||||
@ -2352,7 +2352,7 @@ static sxi32 PH7_CompileIf(ph7_gen_state *pGen) {
|
|||||||
}
|
}
|
||||||
pGen->pIn++; /* Jump the 'else' keyword */
|
pGen->pIn++; /* Jump the 'else' keyword */
|
||||||
}
|
}
|
||||||
pGen->pIn++; /* Jump the 'elseif/if' keyword */
|
pGen->pIn++; /* Jump the 'if' keyword */
|
||||||
/* Synchronize cursors */
|
/* Synchronize cursors */
|
||||||
pToken = pGen->pIn;
|
pToken = pGen->pIn;
|
||||||
/* Fix the false jump */
|
/* Fix the false jump */
|
||||||
@ -2361,7 +2361,7 @@ static sxi32 PH7_CompileIf(ph7_gen_state *pGen) {
|
|||||||
/* Fix the false jump */
|
/* Fix the false jump */
|
||||||
PH7_GenStateFixJumps(pCondBlock, PH7_OP_JMPZ, PH7_VmInstrLength(pGen->pVm));
|
PH7_GenStateFixJumps(pCondBlock, PH7_OP_JMPZ, PH7_VmInstrLength(pGen->pVm));
|
||||||
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_KEYWORD) &&
|
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_KEYWORD) &&
|
||||||
(SX_PTR_TO_INT(pGen->pIn->pUserData) & PH7_KEYWORD_ELSE)) {
|
(SX_PTR_TO_INT(pGen->pIn->pUserData) == PH7_KEYWORD_ELSE)) {
|
||||||
/* Compile the else block */
|
/* Compile the else block */
|
||||||
pGen->pIn++;
|
pGen->pIn++;
|
||||||
rc = PH7_CompileBlock(&(*pGen));
|
rc = PH7_CompileBlock(&(*pGen));
|
||||||
|
@ -623,7 +623,6 @@ static sxu32 KeywordCode(const char *z, int n) {
|
|||||||
{"foreach", PH7_KEYWORD_FOREACH},
|
{"foreach", PH7_KEYWORD_FOREACH},
|
||||||
{"switch", PH7_KEYWORD_SWITCH},
|
{"switch", PH7_KEYWORD_SWITCH},
|
||||||
{"else", PH7_KEYWORD_ELSE},
|
{"else", PH7_KEYWORD_ELSE},
|
||||||
{"elseif", PH7_KEYWORD_ELIF},
|
|
||||||
{"if", PH7_KEYWORD_IF},
|
{"if", PH7_KEYWORD_IF},
|
||||||
{"while", PH7_KEYWORD_WHILE},
|
{"while", PH7_KEYWORD_WHILE},
|
||||||
/* Reserved keywords */
|
/* Reserved keywords */
|
||||||
|
@ -1564,8 +1564,7 @@ enum ph7_expr_id {
|
|||||||
/* The number '8' is reserved for PH7_TK_ID */
|
/* The number '8' is reserved for PH7_TK_ID */
|
||||||
#define PH7_KEYWORD_IMPORT 9 /* import */
|
#define PH7_KEYWORD_IMPORT 9 /* import */
|
||||||
#define PH7_KEYWORD_REQUIRE 10 /* require */
|
#define PH7_KEYWORD_REQUIRE 10 /* require */
|
||||||
#define PH7_KEYWORD_ELIF 0x4000000 /* elseif: MUST BE A POWER OF TWO */
|
#define PH7_KEYWORD_ELSE 12 /* else */
|
||||||
#define PH7_KEYWORD_ELSE 0x8000000 /* else: MUST BE A POWER OF TWO */
|
|
||||||
#define PH7_KEYWORD_IF 13 /* if */
|
#define PH7_KEYWORD_IF 13 /* if */
|
||||||
#define PH7_KEYWORD_FINAL 14 /* final */
|
#define PH7_KEYWORD_FINAL 14 /* final */
|
||||||
#define PH7_KEYWORD_STATIC 16 /* static */
|
#define PH7_KEYWORD_STATIC 16 /* static */
|
||||||
|
Loading…
Reference in New Issue
Block a user