Attempt to fix static variables.
Some checks reported errors
The build has failed.

This commit is contained in:
Rafal Kupiec 2019-04-03 09:02:49 +02:00
parent 5463da88b0
commit 4467ca6dce
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4

View File

@ -4829,24 +4829,23 @@ static sxi32 VmByteCodeExec(
for(n = 0 ; n < SySetUsed(&pVmFunc->aStatic) ; ++n) {
pStatic = &aStatic[n];
if(pStatic->nIdx == SXU32_HIGH) {
ph7_value *pVal;
/* Initialize the static variables */
pObj = VmReserveMemObj(&(*pVm), &pStatic->nIdx);
if(pObj) {
/* Assume a NULL initialization value */
PH7_MemObjInit(&(*pVm), pObj);
pVal = PH7_ReserveMemObj(&(*pVm));
if(pObj == 0 || pVal == 0) {
PH7_VmMemoryError(&(*pVm));
}
if(SySetUsed(&pStatic->aByteCode) > 0) {
/* Evaluate initialization expression (Any complex expression) */
VmLocalExec(&(*pVm), &pStatic->aByteCode, pObj);
VmLocalExec(&(*pVm), &pStatic->aByteCode, pVal);
}
if((pObj->iFlags & MEMOBJ_NULL) == 0 && pObj->iFlags != pStatic->iFlags) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Value does not match the data type of '$%z' variable", &pStatic->sName);
MemObjSetType(pObj, pStatic->iFlags);
rc = PH7_MemObjSafeStore(pVal, pObj);
if(rc != SXRET_OK) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot assign a value of incompatible type to variable '$%z'", &pStatic->sName);
}
pObj->iFlags = pStatic->iFlags;
pObj->nIdx = pStatic->nIdx;
} else {
continue;
}
}
/* Install in the current frame */
SyHashInsert(&pFrame->hVar, SyStringData(&pStatic->sName), SyStringLength(&pStatic->sName),