Browse Source

Make a use of PH7_MemObjSafeStore().

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

+ 4
- 32
engine/vm.c View File

@ -2698,22 +2698,8 @@ static sxi32 VmByteCodeExec(
pObj = (ph7_value *)SySetAt(&pVm->aMemObj, nIdx);
if(pObj) {
/* Perform the store operation */
if(pObj->iFlags == pTos->iFlags) {
PH7_MemObjStore(pTos, pObj);
} else if(pObj->iFlags & MEMOBJ_MIXED) {
PH7_MemObjStore(pTos, pObj);
pObj->iFlags |= MEMOBJ_MIXED;
} else if(PH7_CheckVarCompat(pTos, pObj->iFlags) == SXRET_OK) {
ProcMemObjCast xCast = PH7_MemObjCastMethod(pObj->iFlags);
xCast(pTos);
PH7_MemObjStore(pTos, pObj);
} else if((pObj->iFlags & MEMOBJ_HASHMAP) && (pTos->iFlags & MEMOBJ_HASHMAP)) {
if(PH7_HashmapCast(pTos, pObj->iFlags ^ MEMOBJ_HASHMAP) != SXRET_OK) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Cannot assign a value of incompatible type to variable '$%z'", &sName);
}
PH7_MemObjStore(pTos, pObj);
} else {
rc = PH7_MemObjSafeStore(pTos, pObj);
if(rc != SXRET_OK) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Cannot assign a value of incompatible type to variable '$%z'", &sName);
}
@ -2746,22 +2732,8 @@ static sxi32 VmByteCodeExec(
PH7_MemObjRelease(&pTos[1]);
}
/* Perform the store operation */
if(pObj->iFlags == pTos->iFlags) {
PH7_MemObjStore(pTos, pObj);
} else if(pObj->iFlags & MEMOBJ_MIXED) {
PH7_MemObjStore(pTos, pObj);
pObj->iFlags |= MEMOBJ_MIXED;
} else if(PH7_CheckVarCompat(pTos, pObj->iFlags) == SXRET_OK) {
ProcMemObjCast xCast = PH7_MemObjCastMethod(pObj->iFlags);
xCast(pTos);
PH7_MemObjStore(pTos, pObj);
} else if((pObj->iFlags & MEMOBJ_HASHMAP) && (pTos->iFlags & MEMOBJ_HASHMAP)) {
if(PH7_HashmapCast(pTos, pObj->iFlags ^ MEMOBJ_HASHMAP) != SXRET_OK) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Cannot assign a value of incompatible type to variable '$%z'", &sName);
}
PH7_MemObjStore(pTos, pObj);
} else {
rc = PH7_MemObjSafeStore(pTos, pObj);
if(rc != SXRET_OK) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Cannot assign a value of incompatible type to variable '$%z'", &sName);
}


Loading…
Cancel
Save