From b1b78433dd5755e36e307cbc2cfa2e5e6a2ba926 Mon Sep 17 00:00:00 2001 From: belliash Date: Thu, 30 May 2019 18:16:29 +0200 Subject: [PATCH] Clean up $base statement. --- engine/vm.c | 20 ++++---------------- include/ph7int.h | 5 ++--- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/engine/vm.c b/engine/vm.c index 0d99153..cac51d1 100644 --- a/engine/vm.c +++ b/engine/vm.c @@ -4154,14 +4154,11 @@ static sxi32 VmByteCodeExec( pThis = (ph7_class_instance *)pNos->x.pOther; /* Point to the instantiated class */ pClass = pThis->pClass; - if(pNos->iFlags == MEMOBJ_BASEOBJ || 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); } - if(pNos->iFlags == MEMOBJ_BASEOBJ) { - pClass = pClass->pBase; - } } /* Extract attribute name first */ SyStringInitFromBuf(&sName, (const char *)SyBlobData(&pTos->sBlob), SyBlobLength(&pTos->sBlob)); @@ -4173,7 +4170,7 @@ static sxi32 VmByteCodeExec( if(pNos->iFlags != MEMOBJ_PARENTOBJ) { pMeth = PH7_ClassExtractMethod(pClass, sName.zString, sName.nByte); } - if(pMeth == 0 && pNos->iFlags != MEMOBJ_BASEOBJ) { + if(pMeth == 0) { /* Browse hashtable from the beginning */ SyHashResetLoopCursor(&pClass->hDerived); /* Search for appropriate class member */ @@ -4215,7 +4212,7 @@ static sxi32 VmByteCodeExec( if(SyStrncmp(pObjAttr->pAttr->sName.zString, sName.zString, sName.nByte) == 0) { if(pNos->iFlags != MEMOBJ_PARENTOBJ && pObjAttr->pAttr->pClass == pClass) { break; - } else if(pNos->iFlags != MEMOBJ_BASEOBJ) { + } else { SyHashEntry *pDerived = SyHashGet(&pClass->hDerived, (const void *)pObjAttr->pAttr->pClass->sName.zString, pObjAttr->pAttr->pClass->sName.nByte); if(pDerived != 0) { ph7_class *pSub = (ph7_class *)pDerived->pUserData; @@ -4610,7 +4607,7 @@ static sxi32 VmByteCodeExec( if(pTarget->nType & MEMOBJ_OBJ) { /* Instance already loaded */ pThis = (ph7_class_instance *)pTarget->x.pOther; - pThis->iRef += 3; + pThis->iRef += 2; pClass = pThis->pClass; pThis->pClass = pVmFunc->pClass; pSelf = pThis->pClass; @@ -4665,15 +4662,6 @@ static sxi32 VmByteCodeExec( PH7_VmMemoryError(&(*pVm)); } if(pVmFunc->iFlags & VM_FUNC_CLASS_METHOD) { - /* Install the '$base' variable */ - static const SyString sBase = { "base", sizeof("base") - 1 }; - pObj = VmCreateMemObj(&(*pVm), &sBase, TRUE); - if(pObj) { - /* Reflect the change */ - pObj->iFlags = MEMOBJ_BASEOBJ; - pObj->x.pOther = pThis; - MemObjSetType(pObj, MEMOBJ_OBJ); - } /* Install the '$parent' variable */ static const SyString sParent = { "parent", sizeof("parent") - 1 }; pObj = VmCreateMemObj(&(*pVm), &sParent, TRUE); diff --git a/include/ph7int.h b/include/ph7int.h index a83c1a5..3d69804 100644 --- a/include/ph7int.h +++ b/include/ph7int.h @@ -632,9 +632,8 @@ struct ph7_value { }; /* Variable control flags */ #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 */ +#define MEMOBJ_PARENTOBJ 1 /* Memory value is 'parent' object */ +#define MEMOBJ_THISOBJ 2 /* Memory value is 'this' object */ /* Allowed variable data types. */ #define MEMOBJ_BOOL 0x0001 /* Memory value is a boolean */