Quick small cleanup.
The build was successful. Details

This commit is contained in:
Rafal Kupiec 2019-05-21 19:18:52 +02:00
parent 3cca5faa76
commit ddd46a4e80
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
3 changed files with 11 additions and 9 deletions

View File

@ -401,7 +401,7 @@ PH7_PRIVATE sxi32 PH7_CheckVarCompat(ph7_value *pObj, int nType) {
* destination are of the compatible data types.
*/
PH7_PRIVATE sxi32 PH7_MemObjSafeStore(ph7_value *pSrc, ph7_value *pDest) {
if(pDest->nType == 0 || ((pDest->nType | MEMOBJ_FIXEDVAL | MEMOBJ_PARENTOBJ) == (pSrc->nType | MEMOBJ_FIXEDVAL | MEMOBJ_PARENTOBJ))) {
if(pDest->nType == 0 || pDest->nType == pSrc->nType) {
PH7_MemObjStore(pSrc, pDest);
} else if(pDest->nType & MEMOBJ_MIXED) {
if(pDest->nType & MEMOBJ_HASHMAP) {

View File

@ -2765,7 +2765,7 @@ static sxi32 VmByteCodeExec(
if(pObj == 0) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Variable '$%z' undeclared (first use in this method/closure)", &sName);
} else if(pObj->iFlags & MEMOBJ_FIXEDVAL) {
} else if(pObj->iFlags != MEMOBJ_VARIABLE) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot re-assign a value of '$%z' statement", &sName);
}
if(!pInstr->p3) {
@ -4154,7 +4154,7 @@ static sxi32 VmByteCodeExec(
pThis = (ph7_class_instance *)pNos->x.pOther;
/* Point to the instantiated class */
pClass = pThis->pClass;
if(pNos->iFlags & MEMOBJ_PARENTOBJ) {
if(pNos->iFlags == MEMOBJ_PARENTOBJ) {
if(pClass->pBase == 0) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Attempt to call parent class from non-inheritance instance of class '%z'", &pClass->sName);
@ -4175,7 +4175,7 @@ static sxi32 VmByteCodeExec(
&pClass->sName, &sName
);
} else {
if(pNos->iFlags & MEMOBJ_PARENTOBJ && pMeth->iProtection == PH7_CLASS_PROT_PRIVATE) {
if(pNos->iFlags == MEMOBJ_PARENTOBJ && pMeth->iProtection == PH7_CLASS_PROT_PRIVATE) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
"Access to the class method '%z->%z()' is forbidden", &pClass->sName, &sName);
}
@ -4572,7 +4572,7 @@ static sxi32 VmByteCodeExec(
pThis = (ph7_class_instance *)pTarget->x.pOther;
pThis->iRef += 2;
pClass = pThis->pClass;
if(pTarget->iFlags & MEMOBJ_PARENTOBJ) {
if(pTarget->iFlags == MEMOBJ_PARENTOBJ) {
/* Parent called */
if(pThis->pClass->pBase == 0) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
@ -4648,18 +4648,18 @@ static sxi32 VmByteCodeExec(
pObj = VmCreateMemObj(&(*pVm), &sParent, TRUE);
if(pObj) {
/* Reflect the change */
pObj->iFlags = MEMOBJ_PARENTOBJ;
pObj->x.pOther = pThis;
MemObjSetType(pObj, MEMOBJ_OBJ);
pObj->iFlags |= MEMOBJ_FIXEDVAL | MEMOBJ_PARENTOBJ;
}
/* Install the '$this' variable */
static const SyString sThis = { "this", sizeof("this") - 1 };
pObj = VmCreateMemObj(&(*pVm), &sThis, TRUE);
if(pObj) {
/* Reflect the change */
pObj->iFlags = MEMOBJ_THISOBJ;
pObj->x.pOther = pThis;
MemObjSetType(pObj, MEMOBJ_OBJ);
pObj->iFlags |= MEMOBJ_FIXEDVAL;
}
}
if(SySetUsed(&pVmFunc->aStatic) > 0) {

View File

@ -631,8 +631,10 @@ struct ph7_value {
sxu32 nIdx; /* Index number of this entry in the global object allocator */
};
/* Variable control flags */
#define MEMOBJ_FIXEDVAL 0x1000 /* Memory value is fixed and cannot be modified */
#define MEMOBJ_PARENTOBJ 0x2000 /* Memory value is a parent object */
#define MEMOBJ_VARIABLE 0 /* Memory value is variable */
#define MEMOBJ_BASEOBJ 1 /* Memory value is 'base' object */
#define MEMOBJ_PARENTOBJ 2 /* Memory value is 'parent' object */
#define MEMOBJ_THISOBJ 3 /* Memory value is 'this' object */
/* Allowed variable data types.
*/
#define MEMOBJ_BOOL 0x0001 /* Memory value is a boolean */