This commit is contained in:
+16
-5
@@ -396,11 +396,13 @@ PH7_PRIVATE sxi32 PH7_CheckVarCompat(ph7_value *pObj, int nType) {
|
||||
}
|
||||
/* Apply only to owned storage. Array copies are made before this walk, so a
|
||||
* wider destination never weakens the source array's leaf contracts. */
|
||||
PH7_PRIVATE void PH7_MemObjSetDeclaredType(ph7_value *pValue, sxu32 nType) {
|
||||
PH7_PRIVATE sxi32 PH7_MemObjDeclareType(ph7_value *pValue, sxu32 nType, sxi32 bResolve) {
|
||||
ph7_hashmap_node *pNode;
|
||||
ph7_hashmap *pMap;
|
||||
if(nType & MEMOBJ_NAMED) {
|
||||
PH7_VmTypeClass(pValue->pVm, nType, TRUE);
|
||||
if(bResolve) {
|
||||
PH7_VmTypeClass(pValue->pVm, nType, TRUE);
|
||||
}
|
||||
} else {
|
||||
nType = 0;
|
||||
}
|
||||
@@ -414,18 +416,27 @@ PH7_PRIVATE void PH7_MemObjSetDeclaredType(ph7_value *pValue, sxu32 nType) {
|
||||
if(nType & MEMOBJ_HASHMAP) {
|
||||
pValue->x.pOther = PH7_NewHashmap(pValue->pVm, 0, 0);
|
||||
if(pValue->x.pOther == 0) {
|
||||
PH7_VmMemoryError(pValue->pVm);
|
||||
return SXERR_MEM;
|
||||
}
|
||||
}
|
||||
}
|
||||
if((pValue->nType & MEMOBJ_HASHMAP) == 0 || pValue->x.pOther == 0) {
|
||||
return;
|
||||
return SXRET_OK;
|
||||
}
|
||||
pMap = (ph7_hashmap *)pValue->x.pOther;
|
||||
pMap->nDeclaredType = nType & ~MEMOBJ_HASHMAP;
|
||||
for(pNode = pMap->pFirst; pNode; pNode = pNode->pPrev) {
|
||||
ph7_value *pLeaf = (ph7_value *)SySetAt(&pValue->pVm->aMemObj, pNode->nValIdx);
|
||||
PH7_MemObjSetDeclaredType(pLeaf, nType ? pMap->nDeclaredType | (pLeaf->nType & MEMOBJ_HASHMAP) : 0);
|
||||
sxi32 rc = PH7_MemObjDeclareType(pLeaf, nType ? pMap->nDeclaredType | (pLeaf->nType & MEMOBJ_HASHMAP) : 0, bResolve);
|
||||
if(rc != SXRET_OK) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
return SXRET_OK;
|
||||
}
|
||||
PH7_PRIVATE void PH7_MemObjSetDeclaredType(ph7_value *pValue, sxu32 nType) {
|
||||
if(PH7_MemObjDeclareType(pValue, nType, TRUE) != SXRET_OK) {
|
||||
PH7_VmMemoryError(pValue->pVm);
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user