parent
a0f7949b24
commit
3e18a5b8e8
|
@ -1203,8 +1203,10 @@ static sxi32 PH7_GenStateLoadLiteral(ph7_gen_state *pGen) {
|
|||
/* Emit the load constant instruction */
|
||||
PH7_VmEmitInstr(pGen->pVm, PH7_OP_LOADC, 0, nIdx, 0, 0);
|
||||
return SXRET_OK;
|
||||
} else if(pStr->nByte == sizeof("__FILE__") - 1 &&
|
||||
SyMemcmp(pStr->zString, "__FILE__", sizeof("__FILE__") - 1) == 0) {
|
||||
} else if((pStr->nByte == sizeof("__FILE__") - 1 &&
|
||||
SyMemcmp(pStr->zString, "__FILE__", sizeof("__FILE__") - 1) == 0) ||
|
||||
(pStr->nByte == sizeof("__DIR__") - 1 &&
|
||||
SyMemcmp(pStr->zString, "__DIR__", sizeof("__DIR__") - 1) == 0)) {
|
||||
pObj = PH7_ReserveConstObj(pGen->pVm, &nIdx);
|
||||
if(pObj == 0) {
|
||||
PH7_GenCompileError(pGen, E_ERROR, pToken->nLine, "Fatal, PH7 engine is running out of memory");
|
||||
|
@ -1216,34 +1218,20 @@ static sxi32 PH7_GenStateLoadLiteral(ph7_gen_state *pGen) {
|
|||
SyStringInitFromBuf(&pMemory, ":MEMORY:", (int)sizeof(":MEMORY:") - 1);
|
||||
PH7_MemObjInitFromString(pGen->pVm, pObj, &pMemory);
|
||||
} else {
|
||||
PH7_MemObjInitFromString(pGen->pVm, pObj, pFile);
|
||||
}
|
||||
/* Emit the load constant instruction */
|
||||
PH7_VmEmitInstr(pGen->pVm, PH7_OP_LOADC, 0, nIdx, 0, 0);
|
||||
return SXRET_OK;
|
||||
} else if(pStr->nByte == sizeof("__DIR__") - 1 &&
|
||||
SyMemcmp(pStr->zString, "__DIR__", sizeof("__DIR__") - 1) == 0) {
|
||||
pObj = PH7_ReserveConstObj(pGen->pVm, &nIdx);
|
||||
if(pObj == 0) {
|
||||
PH7_GenCompileError(pGen, E_ERROR, pToken->nLine, "Fatal, PH7 engine is running out of memory");
|
||||
return SXERR_ABORT;
|
||||
}
|
||||
SyString *pFile = (SyString *)SySetPeek(&pGen->pVm->aFiles);
|
||||
if(pFile == 0) {
|
||||
SyString pMemory;
|
||||
SyStringInitFromBuf(&pMemory, ":MEMORY:", (int)sizeof(":MEMORY:") - 1);
|
||||
PH7_MemObjInitFromString(pGen->pVm, pObj, &pMemory);
|
||||
} else {
|
||||
SyString pDir;
|
||||
if(pFile->nByte > 0) {
|
||||
const char *zDir;
|
||||
int nLen;
|
||||
zDir = PH7_ExtractDirName(pFile->zString, (int)pFile->nByte, &nLen);
|
||||
SyStringInitFromBuf(&pDir, zDir, nLen);
|
||||
if(pStr->zString[2] == 'F' /* FILE */) {
|
||||
PH7_MemObjInitFromString(pGen->pVm, pObj, pFile);
|
||||
} else {
|
||||
SyStringInitFromBuf(&pDir, ".", 1);
|
||||
SyString pDir;
|
||||
if(pFile->nByte > 0) {
|
||||
const char *zDir;
|
||||
int nLen;
|
||||
zDir = PH7_ExtractDirName(pFile->zString, (int)pFile->nByte, &nLen);
|
||||
SyStringInitFromBuf(&pDir, zDir, nLen);
|
||||
} else {
|
||||
SyStringInitFromBuf(&pDir, ".", 1);
|
||||
}
|
||||
PH7_MemObjInitFromString(pGen->pVm, pObj, &pDir);
|
||||
}
|
||||
PH7_MemObjInitFromString(pGen->pVm, pObj, &pDir);
|
||||
}
|
||||
/* Emit the load constant instruction */
|
||||
PH7_VmEmitInstr(pGen->pVm, PH7_OP_LOADC, 0, nIdx, 0, 0);
|
||||
|
|
Loading…
Reference in New Issue