Attempt to fix static class attributes.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
8133c3dd6f
commit
d4d00db458
24
engine/vm.c
24
engine/vm.c
|
@ -629,30 +629,24 @@ static sxi32 VmMountUserClass(
|
||||||
/* Extract the current attribute */
|
/* Extract the current attribute */
|
||||||
pAttr = (ph7_class_attr *)pEntry->pUserData;
|
pAttr = (ph7_class_attr *)pEntry->pUserData;
|
||||||
if(pAttr->iFlags & (PH7_CLASS_ATTR_CONSTANT | PH7_CLASS_ATTR_STATIC)) {
|
if(pAttr->iFlags & (PH7_CLASS_ATTR_CONSTANT | PH7_CLASS_ATTR_STATIC)) {
|
||||||
ph7_value *pMemObj;
|
ph7_value *pMemObj, *pResult;
|
||||||
/* Reserve a memory object for this constant/static attribute */
|
/* Reserve a memory object for this constant/static attribute */
|
||||||
pMemObj = PH7_ReserveMemObj(&(*pVm));
|
pMemObj = PH7_ReserveMemObj(&(*pVm));
|
||||||
if(pMemObj == 0) {
|
pResult = PH7_ReserveMemObj(&(*pVm));
|
||||||
|
if(pMemObj == 0 || pResult == 0) {
|
||||||
PH7_VmMemoryError(&(*pVm));
|
PH7_VmMemoryError(&(*pVm));
|
||||||
}
|
}
|
||||||
if(SySetUsed(&pAttr->aByteCode) > 0) {
|
if(SySetUsed(&pAttr->aByteCode) > 0) {
|
||||||
/* Initialize attribute default value (any complex expression) */
|
/* Initialize attribute default value (any complex expression) */
|
||||||
VmLocalExec(&(*pVm), &pAttr->aByteCode, pMemObj);
|
VmLocalExec(&(*pVm), &pAttr->aByteCode, pResult);
|
||||||
}
|
}
|
||||||
if((pAttr->nType & MEMOBJ_MIXED) == 0) {
|
MemObjSetType(pMemObj, pAttr->nType);
|
||||||
if(pAttr->nType != pMemObj->iFlags) {
|
rc = PH7_MemObjSafeStore(pResult, pMemObj);
|
||||||
if(PH7_CheckVarCompat(pMemObj, pAttr->nType) == SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
ProcMemObjCast xCast = PH7_MemObjCastMethod(pAttr->nType);
|
|
||||||
xCast(pMemObj);
|
|
||||||
} else if((pAttr->iFlags & MEMOBJ_HASHMAP) && (pMemObj->iFlags & MEMOBJ_HASHMAP)) {
|
|
||||||
if(PH7_HashmapCast(pMemObj, pAttr->iFlags ^ MEMOBJ_HASHMAP) != SXRET_OK) {
|
|
||||||
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot assign a value of incompatible type to variable '%z::$%z'", &pClass->sName, &pAttr->sName);
|
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot assign a value of incompatible type to variable '%z::$%z'", &pClass->sName, &pAttr->sName);
|
||||||
}
|
}
|
||||||
} else {
|
/* Free up memory */
|
||||||
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot assign a value of incompatible type to variable '%z::$%z'", &pClass->sName, &pAttr->sName);
|
PH7_MemObjRelease(pResult);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Record attribute index */
|
/* Record attribute index */
|
||||||
pAttr->nIdx = pMemObj->nIdx;
|
pAttr->nIdx = pMemObj->nIdx;
|
||||||
/* Install static attribute in the reference table */
|
/* Install static attribute in the reference table */
|
||||||
|
|
Loading…
Reference in New Issue