Browse Source

Implement '$base' construction.

release/v0.1
Rafal Kupiec 1 year ago
parent
commit
5b2f300fe4
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      engine/vm.c

+ 10
- 1
engine/vm.c View File

@ -4570,7 +4570,7 @@ static sxi32 VmByteCodeExec(
if(pTarget->nType & MEMOBJ_OBJ) {
/* Instance already loaded */
pThis = (ph7_class_instance *)pTarget->x.pOther;
pThis->iRef += 2;
pThis->iRef += 3;
pClass = pThis->pClass;
if(pTarget->iFlags == MEMOBJ_PARENTOBJ) {
/* Parent called */
@ -4643,6 +4643,15 @@ 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);

Loading…
Cancel
Save