Extend native class API to support full AerScript declarations
Build / AerScript (push) Successful in 18s

This commit is contained in:
2026-11-18 20:57:39 +01:00
parent 61006fe848
commit 58f604aea5
10 changed files with 1556 additions and 328 deletions
+10 -18
View File
@@ -3765,14 +3765,15 @@ static sxi32 PH7_GenStateCompileClassConstant(ph7_gen_state *pGen, sxi32 iProtec
SyString *pName;
sxi32 rc;
/* Extract visibility level */
iProtection = PH7_GetProtectionLevel(iProtection);
iProtection = PH7_ClassConstantProtection(pClass, PH7_GetProtectionLevel(iProtection));
pGen->pIn++; /* Jump the 'const' keyword */
loop:
/* Mark as constant */
iFlags |= PH7_CLASS_ATTR_CONSTANT;
if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & PH7_TK_ID) == 0) {
/* Invalid constant name */
PH7_GenCompileError(pGen, E_ERROR, nLine, "Invalid constant name '%z' in class '%z'", &pGen->pIn->sData, pClass->sName);
PH7_GenCompileError(pGen, E_ERROR, nLine, "Invalid constant name '%z' in class '%z'",
pGen->pIn < pGen->pEnd ? &pGen->pIn->sData : &pClass->sName, &pClass->sName);
}
/* Peek constant name */
pName = &pGen->pIn->sData;
@@ -3964,26 +3965,17 @@ static sxi32 PH7_GenStateCompileClassMethod(
/* Peek method name */
pName = &pGen->pIn->sData;
nLine = pGen->pIn->nLine;
if(((pName->nByte == sizeof("__construct") - 1 &&
SyMemcmp(pName->zString, "__construct", sizeof("__construct") - 1) == 0) ||
(pName->nByte == sizeof("__destruct") - 1 &&
SyMemcmp(pName->zString, "__destruct", sizeof("__destruct") - 1) == 0)) && nType != MEMOBJ_VOID) {
PH7_GenCompileError(pGen, E_ERROR, nLine, "Method '%z::%z()' must return void", &pClass->sName, pName);
{
const char *zError = PH7_ClassMethodDeclarationError(pClass, pName, nType,
iProtection, iFlags);
if(zError) {
PH7_GenCompileError(pGen, E_ERROR, nLine, zError, &pClass->sName, pName);
}
}
/* Jump the method name */
pGen->pIn++;
if(iFlags & PH7_CLASS_ATTR_VIRTUAL) {
/* Virtual method */
if(iProtection == PH7_CLASS_PROT_PRIVATE) {
PH7_GenCompileError(pGen, E_ERROR, nLine,
"Virtual method '%z::%z()' cannot be declared private",
&pClass->sName, pName);
}
if((pClass->iFlags & PH7_CLASS_VIRTUAL) == 0) {
PH7_GenCompileError(pGen, E_ERROR, nLine,
"A method '%z::%z()' cannot be declared as virtual in non-virtual class",
&pClass->sName, pName);
}
/* Assemble method signature only */
doBody = FALSE;
}
@@ -4165,7 +4157,7 @@ static sxi32 PH7_CompileClassInterface(ph7_gen_state *pGen) {
/* Preserve constant visibility recovery; non-public methods are fatal. */
PH7_GenCompileError(&(*pGen),
pGen->pIn + 1 < pGen->pEnd && SX_PTR_TO_INT(pGen->pIn[1].pUserData) == PH7_KEYWORD_CONST ? E_WARNING : E_ERROR,
pGen->pIn->nLine, "interface: Access type must be public");
pGen->pIn->nLine, PH7_INTERFACE_VISIBILITY_ERROR);
nKwrd = PH7_KEYWORD_PUBLIC;
}
if(nKwrd == PH7_KEYWORD_PUBLIC) {