Store a pointer to class container to reduce memory usage.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
7203492763
commit
e8c675bd8e
|
@ -3215,7 +3215,7 @@ loop:
|
||||||
}
|
}
|
||||||
pGen->pIn++; /* Jump the equal sign */
|
pGen->pIn++; /* Jump the equal sign */
|
||||||
/* Allocate a new class attribute */
|
/* Allocate a new class attribute */
|
||||||
pCons = PH7_NewClassAttr(pGen->pVm, &pClass->sName, pName, nLine, iProtection, iFlags, 0);
|
pCons = PH7_NewClassAttr(pGen->pVm, pClass, pName, nLine, iProtection, iFlags, 0);
|
||||||
if(pCons == 0) {
|
if(pCons == 0) {
|
||||||
PH7_GenCompileError(pGen, E_ERROR, nLine, "PH7 is running out-of-memory");
|
PH7_GenCompileError(pGen, E_ERROR, nLine, "PH7 is running out-of-memory");
|
||||||
}
|
}
|
||||||
|
@ -3308,7 +3308,7 @@ loop:
|
||||||
PH7_GenCompileError(pGen, E_ERROR, nLine, "Expected '=' or ';' after attribute name '%z'", pName);
|
PH7_GenCompileError(pGen, E_ERROR, nLine, "Expected '=' or ';' after attribute name '%z'", pName);
|
||||||
}
|
}
|
||||||
/* Allocate a new class attribute */
|
/* Allocate a new class attribute */
|
||||||
pAttr = PH7_NewClassAttr(pGen->pVm, &pClass->sName, pName, nLine, iProtection, iFlags, nType);
|
pAttr = PH7_NewClassAttr(pGen->pVm, pClass, pName, nLine, iProtection, iFlags, nType);
|
||||||
if(pAttr == 0) {
|
if(pAttr == 0) {
|
||||||
PH7_GenCompileError(pGen, E_ERROR, nLine, "PH7 engine is running out-of-memory");
|
PH7_GenCompileError(pGen, E_ERROR, nLine, "PH7 engine is running out-of-memory");
|
||||||
}
|
}
|
||||||
|
|
10
engine/oop.c
10
engine/oop.c
|
@ -67,7 +67,7 @@ PH7_PRIVATE ph7_class *PH7_NewRawClass(ph7_vm *pVm, const SyString *pName) {
|
||||||
* Allocate and initialize a new class attribute.
|
* Allocate and initialize a new class attribute.
|
||||||
* Return a pointer to the class attribute on success. NULL otherwise.
|
* Return a pointer to the class attribute on success. NULL otherwise.
|
||||||
*/
|
*/
|
||||||
PH7_PRIVATE ph7_class_attr *PH7_NewClassAttr(ph7_vm *pVm, const SyString *pClass, const SyString *pName, sxu32 nLine, sxi32 iProtection, sxi32 iFlags, sxu32 nType) {
|
PH7_PRIVATE ph7_class_attr *PH7_NewClassAttr(ph7_vm *pVm, ph7_class *pClass, const SyString *pName, sxu32 nLine, sxi32 iProtection, sxi32 iFlags, sxu32 nType) {
|
||||||
ph7_class_attr *pAttr;
|
ph7_class_attr *pAttr;
|
||||||
char *zName;
|
char *zName;
|
||||||
pAttr = (ph7_class_attr *)SyMemBackendPoolAlloc(&pVm->sAllocator, sizeof(ph7_class_attr));
|
pAttr = (ph7_class_attr *)SyMemBackendPoolAlloc(&pVm->sAllocator, sizeof(ph7_class_attr));
|
||||||
|
@ -83,14 +83,8 @@ PH7_PRIVATE ph7_class_attr *PH7_NewClassAttr(ph7_vm *pVm, const SyString *pClass
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SyStringInitFromBuf(&pAttr->sName, zName, pName->nByte);
|
SyStringInitFromBuf(&pAttr->sName, zName, pName->nByte);
|
||||||
/* Duplicate class name */
|
|
||||||
zName = SyMemBackendStrDup(&pVm->sAllocator, pClass->zString, pClass->nByte);
|
|
||||||
if(zName == 0) {
|
|
||||||
SyMemBackendPoolFree(&pVm->sAllocator, pAttr);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
SyStringInitFromBuf(&pAttr->sClass, zName, pName->nByte);
|
|
||||||
/* Initialize fields */
|
/* Initialize fields */
|
||||||
|
pAttr->pClass = pClass;
|
||||||
SySetInit(&pAttr->aByteCode, &pVm->sAllocator, sizeof(VmInstr));
|
SySetInit(&pAttr->aByteCode, &pVm->sAllocator, sizeof(VmInstr));
|
||||||
pAttr->iProtection = iProtection;
|
pAttr->iProtection = iProtection;
|
||||||
pAttr->nIdx = SXU32_HIGH;
|
pAttr->nIdx = SXU32_HIGH;
|
||||||
|
|
|
@ -1066,8 +1066,8 @@ struct ph7_class {
|
||||||
* in an instance of the following structure.
|
* in an instance of the following structure.
|
||||||
*/
|
*/
|
||||||
struct ph7_class_attr {
|
struct ph7_class_attr {
|
||||||
SyString sClass; /* Class name */
|
|
||||||
SyString sName; /* Attribute name */
|
SyString sName; /* Attribute name */
|
||||||
|
ph7_class *pClass; /* Class, the attribute was declared */
|
||||||
sxi32 iFlags; /* Attribute configuration [i.e: static, variable, constant, etc.] */
|
sxi32 iFlags; /* Attribute configuration [i.e: static, variable, constant, etc.] */
|
||||||
sxi32 iProtection; /* Protection level [i.e: public, private, protected] */
|
sxi32 iProtection; /* Protection level [i.e: public, private, protected] */
|
||||||
SySet aByteCode; /* Compiled attribute body */
|
SySet aByteCode; /* Compiled attribute body */
|
||||||
|
@ -1757,7 +1757,7 @@ PH7_PRIVATE sxi32 PH7_ParseIniString(ph7_context *pCtx, const char *zIn, sxu32 n
|
||||||
/* oo.c function prototypes */
|
/* oo.c function prototypes */
|
||||||
PH7_PRIVATE ph7_class_info *PH7_NewClassInfo(ph7_vm *pVm, const SyString *pName);
|
PH7_PRIVATE ph7_class_info *PH7_NewClassInfo(ph7_vm *pVm, const SyString *pName);
|
||||||
PH7_PRIVATE ph7_class *PH7_NewRawClass(ph7_vm *pVm, const SyString *pName);
|
PH7_PRIVATE ph7_class *PH7_NewRawClass(ph7_vm *pVm, const SyString *pName);
|
||||||
PH7_PRIVATE ph7_class_attr *PH7_NewClassAttr(ph7_vm *pVm, const SyString *pClass, const SyString *pName, sxu32 nLine, sxi32 iProtection, sxi32 iFlags, sxu32 nType);
|
PH7_PRIVATE ph7_class_attr *PH7_NewClassAttr(ph7_vm *pVm, ph7_class *pClass, const SyString *pName, sxu32 nLine, sxi32 iProtection, sxi32 iFlags, sxu32 nType);
|
||||||
PH7_PRIVATE ph7_class_method *PH7_NewClassMethod(ph7_vm *pVm, ph7_class *pClass, const SyString *pName, sxu32 nLine,
|
PH7_PRIVATE ph7_class_method *PH7_NewClassMethod(ph7_vm *pVm, ph7_class *pClass, const SyString *pName, sxu32 nLine,
|
||||||
sxi32 iProtection, sxi32 iFlags, sxi32 iFuncFlags);
|
sxi32 iProtection, sxi32 iFlags, sxi32 iFuncFlags);
|
||||||
PH7_PRIVATE ph7_class_method *PH7_ClassExtractMethod(ph7_class *pClass, const char *zName, sxu32 nByte);
|
PH7_PRIVATE ph7_class_method *PH7_ClassExtractMethod(ph7_class *pClass, const char *zName, sxu32 nByte);
|
||||||
|
|
Loading…
Reference in New Issue