This commit is contained in:
+4
-28
@@ -1003,23 +1003,11 @@ PH7_PRIVATE sxi32 PH7_CompileArray(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
}
|
||||
/* Names, not class pointers, survive forward declarations and arena growth. */
|
||||
static sxu32 GenStateNamedType(ph7_gen_state *pGen, SyString *pName) {
|
||||
SyString sName;
|
||||
sxu32 i;
|
||||
char *zName;
|
||||
for(i = 0; i < SySetUsed(&pGen->pVm->aTypeNames); i++) {
|
||||
if(SyStringCmp(pName, (SyString *)SySetAt(&pGen->pVm->aTypeNames, i), SyMemcmp) == 0) {
|
||||
return ((i + 1) << 12) | MEMOBJ_OBJ;
|
||||
}
|
||||
}
|
||||
zName = SyMemBackendStrDup(&pGen->pVm->sAllocator, pName->zString, pName->nByte);
|
||||
if(zName == 0 || i >= (MEMOBJ_NAMED >> 12)) {
|
||||
sxu32 nType = 0;
|
||||
if(PH7_VmInternType(pGen->pVm, pName, &nType) != SXRET_OK) {
|
||||
PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine, "PH7 engine is running out-of-memory");
|
||||
}
|
||||
SyStringInitFromBuf(&sName, zName, pName->nByte);
|
||||
if(SySetPut(&pGen->pVm->aTypeNames, &sName) != SXRET_OK) {
|
||||
PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine, "PH7 engine is running out-of-memory");
|
||||
}
|
||||
return ((i + 1) << 12) | MEMOBJ_OBJ;
|
||||
return nType;
|
||||
}
|
||||
/*
|
||||
* Classify a literal expression node for the static comparison checks.
|
||||
@@ -1636,19 +1624,7 @@ PH7_PRIVATE sxi32 PH7_CompileLiteral(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
* Return TRUE if reserved. FALSE otherwise.
|
||||
*/
|
||||
static int PH7_GenStateIsReservedConstant(SyString *pName) {
|
||||
if(pName->nByte == sizeof("null") - 1) {
|
||||
if(SyStrnicmp(pName->zString, "null", sizeof("null") - 1) == 0) {
|
||||
return TRUE;
|
||||
} else if(SyStrnicmp(pName->zString, "true", sizeof("true") - 1) == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
} else if(pName->nByte == sizeof("false") - 1) {
|
||||
if(SyStrnicmp(pName->zString, "false", sizeof("false") - 1) == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
/* Not a reserved constant */
|
||||
return FALSE;
|
||||
return PH7_IsReservedConstant(pName);
|
||||
}
|
||||
/*
|
||||
* Compile the 'const' statement.
|
||||
|
||||
Reference in New Issue
Block a user