Create a variable only on OP_LOAD.
The build has failed. Details

This commit is contained in:
Rafal Kupiec 2018-09-23 17:40:26 +02:00
parent 28a5fa59ad
commit ae0fde152c
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
1 changed files with 20 additions and 17 deletions

View File

@ -2355,7 +2355,7 @@ static sxi32 VmByteCodeExec(
break; break;
} }
/* /*
* LOAD: P1 * P3 * LOAD: * P2 P3
* *
* Load a variable where it's name is taken from the top of the stack or * Load a variable where it's name is taken from the top of the stack or
* from the P3 operand. * from the P3 operand.
@ -2383,21 +2383,24 @@ static sxi32 VmByteCodeExec(
pTos++; pTos++;
} }
/* Extract the requested memory object */ /* Extract the requested memory object */
pObj = VmExtractMemObj(&(*pVm), &sName, pInstr->p3 ? FALSE : TRUE, pInstr->iP1 != 1); pObj = VmExtractMemObj(&(*pVm), &sName, pInstr->p3 ? FALSE : TRUE, FALSE);
if(pObj == 0) { if(pInstr->iP2) {
if(pInstr->iP1) { if(pObj) {
/* Variable not found,load NULL */ PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
if(!pInstr->p3) { "Redeclaration of $%z variable", &sName);
PH7_MemObjRelease(pTos); }
} else { if(!pInstr->p3) {
MemObjSetType(pTos, MEMOBJ_NULL); PH7_MemObjRelease(pTos);
}
pTos->nIdx = SXU32_HIGH; /* Mark as constant */
break;
} else { } else {
pObj = VmExtractMemObj(&(*pVm), &sName, FALSE, TRUE);
MemObjSetType(pObj, pInstr->iP2);
}
pTos->nIdx = SXU32_HIGH; /* Mark as constant */
break;
} else {
if(pObj == 0) {
/* Fatal error */ /* Fatal error */
PH7_VmMemoryError(&(*pVm)); PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Variable '$%z' undeclared (first use in this method/closure)", &sName);
goto Abort;
} }
} }
/* Load variable contents */ /* Load variable contents */
@ -2719,10 +2722,10 @@ static sxi32 VmByteCodeExec(
SyStringInitFromBuf(&sName, pInstr->p3, SyStrlen((const char *)pInstr->p3)); SyStringInitFromBuf(&sName, pInstr->p3, SyStrlen((const char *)pInstr->p3));
} }
/* Extract the desired variable and if not available dynamically create it */ /* Extract the desired variable and if not available dynamically create it */
pObj = VmExtractMemObj(&(*pVm), &sName, pInstr->p3 ? FALSE : TRUE, TRUE); pObj = VmExtractMemObj(&(*pVm), &sName, pInstr->p3 ? FALSE : TRUE, FALSE);
if(pObj == 0) { if(pObj == 0) {
PH7_VmMemoryError(&(*pVm)); PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
goto Abort; "Variable '$%z' undeclared (first use in this method/closure)", &sName);
} }
if(!pInstr->p3) { if(!pInstr->p3) {
PH7_MemObjRelease(&pTos[1]); PH7_MemObjRelease(&pTos[1]);