This commit is contained in:
parent
5463da88b0
commit
4467ca6dce
29
engine/vm.c
29
engine/vm.c
@ -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…
Reference in New Issue
Block a user