Do not count compilation errors.
The build was successful. Details

Interpreter will abort script execution on first error found.
This commit is contained in:
Rafal Kupiec 2019-04-24 23:22:06 +02:00
parent 48a38dc1af
commit c443a38fec
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
4 changed files with 25 additions and 51 deletions

View File

@ -695,15 +695,14 @@ static sxi32 ProcessSourceFile(
} }
/* Compile the script */ /* Compile the script */
PH7_CompileAerScript(pVm, &(*pScript), PH7_AERSCRIPT_CODE); PH7_CompileAerScript(pVm, &(*pScript), PH7_AERSCRIPT_CODE);
if(pVm->sCodeGen.nErr > 0 || pVm == 0) { if(pVm == 0) {
sxu32 nErr = pVm->sCodeGen.nErr; /* Null ppVm pointer,release this VM */
/* Compilation error or null ppVm pointer,release this VM */
SyMemBackendRelease(&pVm->sAllocator); SyMemBackendRelease(&pVm->sAllocator);
SyMemBackendPoolFree(&pEngine->sAllocator, pVm); SyMemBackendPoolFree(&pEngine->sAllocator, pVm);
if(ppVm) { if(ppVm) {
*ppVm = 0; *ppVm = 0;
} }
return nErr > 0 ? PH7_COMPILE_ERR : PH7_OK; return PH7_OK;
} }
/* Prepare the virtual machine for bytecode execution */ /* Prepare the virtual machine for bytecode execution */
rc = PH7_VmMakeReady(pVm); rc = PH7_VmMakeReady(pVm);

View File

@ -4953,7 +4953,6 @@ PH7_PRIVATE sxi32 PH7_ResetCodeGenerator(
pGen->pCurrent = &pGen->sGlobal; pGen->pCurrent = &pGen->sGlobal;
pGen->pRawIn = pGen->pRawEnd = 0; pGen->pRawIn = pGen->pRawEnd = 0;
pGen->pIn = pGen->pEnd = 0; pGen->pIn = pGen->pEnd = 0;
pGen->nErr = 0;
return SXRET_OK; return SXRET_OK;
} }
/* /*
@ -4972,22 +4971,6 @@ PH7_PRIVATE sxi32 PH7_GenCompileError(ph7_gen_state *pGen, sxi32 nErrType, sxu32
SyBlobReset(pWorker); SyBlobReset(pWorker);
/* Peek the processed file path if available */ /* Peek the processed file path if available */
pFile = (SyString *)SySetPeek(&pGen->pVm->aFiles); pFile = (SyString *)SySetPeek(&pGen->pVm->aFiles);
if(nErrType == E_ERROR) {
/* Increment the error counter */
pGen->nErr++;
if(pGen->nErr > 15) {
/* Error count limit reached */
if(pGen->xErr) {
SyBlobFormat(pWorker, "%u Error count limit reached,PH7 is aborting compilation\n", nLine);
if(SyBlobLength(pWorker) > 0) {
/* Consume the generated error message */
pGen->xErr(SyBlobData(pWorker), SyBlobLength(pWorker), pGen->pErrData);
}
}
/* Abort immediately */
return SXERR_ABORT;
}
}
if(pGen->xErr == 0) { if(pGen->xErr == 0) {
/* No available error consumer,return immediately */ /* No available error consumer,return immediately */
return SXRET_OK; return SXRET_OK;

View File

@ -9479,41 +9479,34 @@ static sxi32 VmEvalChunk(
} }
/* Compile the chunk */ /* Compile the chunk */
PH7_CompileAerScript(pVm, pChunk, iFlags); PH7_CompileAerScript(pVm, pChunk, iFlags);
if(pVm->sCodeGen.nErr > 0) { ph7_value sResult; /* Return value */
/* Compilation error,return false */ SyHashEntry *pEntry;
if(pCtx) { /* Initialize and install static and constants class attributes */
ph7_result_bool(pCtx, 0); SyHashResetLoopCursor(&pVm->hClass);
} while((pEntry = SyHashGetNextEntry(&pVm->hClass)) != 0) {
} else { if(VmMountUserClass(&(*pVm), (ph7_class *)pEntry->pUserData) != SXRET_OK) {
ph7_value sResult; /* Return value */
SyHashEntry *pEntry;
/* Initialize and install static and constants class attributes */
SyHashResetLoopCursor(&pVm->hClass);
while((pEntry = SyHashGetNextEntry(&pVm->hClass)) != 0) {
if(VmMountUserClass(&(*pVm), (ph7_class *)pEntry->pUserData) != SXRET_OK) {
if(pCtx) {
ph7_result_bool(pCtx, 0);
}
goto Cleanup;
}
}
if(SXRET_OK != PH7_VmEmitInstr(pVm, 0, PH7_OP_DONE, 0, 0, 0, 0)) {
/* Out of memory */
if(pCtx) { if(pCtx) {
ph7_result_bool(pCtx, 0); ph7_result_bool(pCtx, 0);
} }
goto Cleanup; goto Cleanup;
} }
/* Assume a boolean true return value */
PH7_MemObjInitFromBool(pVm, &sResult, 1);
/* Execute the compiled chunk */
VmLocalExec(pVm, &aByteCode, &sResult);
if(pCtx) {
/* Set the execution result */
ph7_result_value(pCtx, &sResult);
}
PH7_MemObjRelease(&sResult);
} }
if(SXRET_OK != PH7_VmEmitInstr(pVm, 0, PH7_OP_DONE, 0, 0, 0, 0)) {
/* Out of memory */
if(pCtx) {
ph7_result_bool(pCtx, 0);
}
goto Cleanup;
}
/* Assume a boolean true return value */
PH7_MemObjInitFromBool(pVm, &sResult, 1);
/* Execute the compiled chunk */
VmLocalExec(pVm, &aByteCode, &sResult);
if(pCtx) {
/* Set the execution result */
ph7_result_value(pCtx, &sResult);
}
PH7_MemObjRelease(&sResult);
Cleanup: Cleanup:
/* Cleanup the mess left behind */ /* Cleanup the mess left behind */
pVm->pByteContainer = pByteCode; pVm->pByteContainer = pByteCode;

View File

@ -904,7 +904,6 @@ struct ph7_gen_state {
SyBlob sErrBuf; /* Error buffer */ SyBlob sErrBuf; /* Error buffer */
SyToken *pIn; /* Current processed token */ SyToken *pIn; /* Current processed token */
SyToken *pEnd; /* Last token in the stream */ SyToken *pEnd; /* Last token in the stream */
sxu32 nErr; /* Total number of compilation error */
SyToken *pRawIn; /* Current processed raw token */ SyToken *pRawIn; /* Current processed raw token */
SyToken *pRawEnd; /* Last raw token in the stream */ SyToken *pRawEnd; /* Last raw token in the stream */
SySet *pTokenSet; /* Token containers */ SySet *pTokenSet; /* Token containers */