Browse Source

Finally, do it the proper way. This should fix all problems with accessing class attributes, at least I hope so.

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

+ 33
- 9
engine/vm.c View File

@ -4203,20 +4203,44 @@ static sxi32 VmByteCodeExec(
} else {
/* Attribute access */
VmClassAttr *pObjAttr = 0;
ph7_class_attr *pAttr = 0;
SyHashEntry *pEntry;
/* Extract the target attribute */
if(sName.nByte > 0) {
SyHashResetLoopCursor(&pThis->hAttr);
while((pEntry = SyHashGetNextEntry(&pThis->hAttr)) != 0) {
pObjAttr = (VmClassAttr *)pEntry->pUserData;
if(SyStrncmp(pObjAttr->pAttr->sName.zString, sName.zString, sName.nByte) == 0) {
if(pNos->iFlags != MEMOBJ_PARENTOBJ && pObjAttr->pAttr->pClass == pClass) {
break;
} else if(pObjAttr->pAttr->pClass != pClass) {
/* Extract the target attribute */
if(pNos->iFlags != MEMOBJ_PARENTOBJ) {
pAttr = PH7_ClassExtractAttribute(pClass, sName.zString, sName.nByte);
}
if(pAttr == 0) {
/* Browse hashtable from the beginning */
SyHashResetLoopCursor(&pClass->hDerived);
/* Search for appropriate class member */
SyHashEntry *pEntry;
while((pEntry = SyHashGetNextEntry(&pClass->hDerived)) != 0) {
pDerived = (ph7_class *) pEntry->pUserData;
SyHashResetLoopCursor(&pDerived->hAttr);
while((pEntry = SyHashGetNextEntry(&pDerived->hAttr)) != 0) {
pAttr = (ph7_class_attr *)pEntry->pUserData;
if(SyStrncmp(pAttr->sName.zString, sName.zString, sName.nByte) == 0) {
break;
}
pAttr = 0;
}
if(pAttr) {
break;
}
}
pObjAttr = 0;
}
if(pAttr) {
SyHashResetLoopCursor(&pThis->hAttr);
while((pEntry = SyHashGetNextEntry(&pThis->hAttr)) != 0) {
pObjAttr = (VmClassAttr *)pEntry->pUserData;
if(pObjAttr->pAttr->pClass == pAttr->pClass) {
if(SyStrncmp(pObjAttr->pAttr->sName.zString, sName.zString, sName.nByte) == 0) {
break;
}
}
pObjAttr = 0;
}
}
}
if(pObjAttr == 0) {

Loading…
Cancel
Save