Attempt to fix '$this' and '$parent' constructs.
All checks were successful
The build was successful.
All checks were successful
The build was successful.
This commit is contained in:
parent
ea5499f8b3
commit
5256dda922
@ -260,11 +260,9 @@ PH7_PRIVATE sxi32 PH7_ClassInherit(ph7_vm *pVm, ph7_class *pSub, ph7_class *pBas
|
||||
continue;
|
||||
}
|
||||
/* Install the attribute */
|
||||
if(pAttr->iProtection != PH7_CLASS_PROT_PRIVATE) {
|
||||
rc = SyHashInsert(&pSub->hAttr, (const void *)pName->zString, pName->nByte, pAttr);
|
||||
if(rc != SXRET_OK) {
|
||||
return rc;
|
||||
}
|
||||
rc = SyHashInsert(&pSub->hAttr, (const void *)pName->zString, pName->nByte, pAttr);
|
||||
if(rc != SXRET_OK) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
SyHashResetLoopCursor(&pBase->hMethod);
|
||||
|
16
engine/vm.c
16
engine/vm.c
@ -4548,6 +4548,7 @@ static sxi32 VmByteCodeExec(
|
||||
if(pEntry) {
|
||||
ph7_vm_func_arg *aFormalArg;
|
||||
ph7_class_instance *pThis;
|
||||
ph7_class *pClass;
|
||||
ph7_value *pFrameStack;
|
||||
ph7_vm_func *pVmFunc;
|
||||
ph7_class *pSelf;
|
||||
@ -4559,6 +4560,7 @@ static sxi32 VmByteCodeExec(
|
||||
pVmFunc = (ph7_vm_func *)pEntry->pUserData;
|
||||
pThis = 0;
|
||||
pSelf = 0;
|
||||
pClass = 0;
|
||||
if(pVmFunc->iFlags & VM_FUNC_CLASS_METHOD) {
|
||||
ph7_class_method *pMeth;
|
||||
/* Class method call */
|
||||
@ -4569,6 +4571,16 @@ static sxi32 VmByteCodeExec(
|
||||
/* Instance already loaded */
|
||||
pThis = (ph7_class_instance *)pTarget->x.pOther;
|
||||
pThis->iRef += 2;
|
||||
pClass = pThis->pClass;
|
||||
if(pTarget->iFlags & MEMOBJ_PARENTOBJ) {
|
||||
/* Parent called */
|
||||
if(pThis->pClass->pBase == 0) {
|
||||
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
|
||||
"Attempt to call parent class from non-inheritance instance of class '%z'", &pClass->sName);
|
||||
}
|
||||
/* Swap to parent class */
|
||||
pThis->pClass = pThis->pClass->pBase;
|
||||
}
|
||||
pSelf = pThis->pClass;
|
||||
}
|
||||
if(pSelf == 0) {
|
||||
@ -4925,6 +4937,10 @@ static sxi32 VmByteCodeExec(
|
||||
SyMemBackendFree(&pVm->sAllocator, pFrameStack);
|
||||
/* Leave the frame */
|
||||
VmLeaveFrame(&(*pVm));
|
||||
if(pClass != 0) {
|
||||
/* Restore original class */
|
||||
pThis->pClass = pClass;
|
||||
}
|
||||
if(rc == PH7_ABORT) {
|
||||
/* Abort processing immediately */
|
||||
goto Abort;
|
||||
|
Loading…
Reference in New Issue
Block a user