Implement C3 class linearization and validate inheritance graphs
Build / AerScript (push) Successful in 2m13s

This commit is contained in:
2026-10-24 01:16:34 +02:00
parent 323793153c
commit bc5e5f6a8e
4 changed files with 172 additions and 30 deletions
+3 -4
View File
@@ -3749,6 +3749,7 @@ static sxi32 PH7_GenStateCompileClass(ph7_gen_state *pGen, sxi32 iFlags) {
if(pClassInfo == 0) {
PH7_GenCompileError(pGen, E_ERROR, nLine, "PH7 is running out-of-memory");
}
pClass->pInfo = pClassInfo;
/* Assume a standalone class */
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_KEYWORD)) {
SyString pBaseName;
@@ -3987,10 +3988,8 @@ static sxi32 PH7_GenStateCompileClass(ph7_gen_state *pGen, sxi32 iFlags) {
}
/* Install the class */
rc = PH7_VmInstallClass(pGen->pVm, pClass);
if(iP1 || iP2) {
/* Emit the CLASS_INIT instruction only if there is such a need */
PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_CLASS_INIT, iP1, iP2, pClassInfo, 0);
}
/* Root classes also need their singleton MRO initialized. */
PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_CLASS_INIT, iP1, iP2, pClassInfo, 0);
if(rc != SXRET_OK) {
PH7_GenCompileError(pGen, E_ERROR, nLine, "PH7 is running out-of-memory");
}