Browse Source

Attempt to fix static variables.

pull/50/head
Rafal Kupiec 2 years ago
parent
commit
4467ca6dce
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
1 changed files with 14 additions and 15 deletions
  1. +14
    -15
      engine/vm.c

+ 14
- 15
engine/vm.c 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);
if(SySetUsed(&pStatic->aByteCode) > 0) {
/* Evaluate initialization expression (Any complex expression) */
VmLocalExec(&(*pVm), &pStatic->aByteCode, pObj);
}
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);
}
pObj->iFlags = pStatic->iFlags;
pObj->nIdx = pStatic->nIdx;
} else {
continue;
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, pVal);
}
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->nIdx = pStatic->nIdx;
}
/* Install in the current frame */
SyHashInsert(&pFrame->hVar, SyStringData(&pStatic->sName), SyStringLength(&pStatic->sName),


Loading…
Cancel
Save