Assign Program::main() return value as program exit code.
The build has failed.
Details
The build has failed.
Details
This commit is contained in:
parent
7a740c0570
commit
c8e2dccbeb
23
engine/vm.c
23
engine/vm.c
|
@ -1084,8 +1084,6 @@ PH7_PRIVATE sxi32 PH7_VmMakeReady(
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
return SXERR_MEM;
|
return SXERR_MEM;
|
||||||
}
|
}
|
||||||
/* Script return value */
|
|
||||||
PH7_MemObjInit(&(*pVm), &pVm->sExec); /* Assume a NULL return value */
|
|
||||||
/* Allocate a new operand stack */
|
/* Allocate a new operand stack */
|
||||||
pVm->aOps = VmNewOperandStack(&(*pVm), SySetUsed(pVm->pByteContainer));
|
pVm->aOps = VmNewOperandStack(&(*pVm), SySetUsed(pVm->pByteContainer));
|
||||||
if(pVm->aOps == 0) {
|
if(pVm->aOps == 0) {
|
||||||
|
@ -1138,7 +1136,6 @@ PH7_PRIVATE sxi32 PH7_VmReset(ph7_vm *pVm) {
|
||||||
}
|
}
|
||||||
/* TICKET 1433-003: As of this version, the VM is automatically reset */
|
/* TICKET 1433-003: As of this version, the VM is automatically reset */
|
||||||
SyBlobReset(&pVm->sConsumer);
|
SyBlobReset(&pVm->sConsumer);
|
||||||
PH7_MemObjRelease(&pVm->sExec);
|
|
||||||
/* Set the ready flag */
|
/* Set the ready flag */
|
||||||
pVm->nMagic = PH7_VM_RUN;
|
pVm->nMagic = PH7_VM_RUN;
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
|
@ -1701,18 +1698,6 @@ PH7_PRIVATE sxi32 PH7_VmConfigure(
|
||||||
pVm->xErrLog = xErrLog;
|
pVm->xErrLog = xErrLog;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PH7_VM_CONFIG_EXEC_VALUE: {
|
|
||||||
/* Script return value */
|
|
||||||
ph7_value **ppValue = va_arg(ap, ph7_value **);
|
|
||||||
#ifdef UNTRUST
|
|
||||||
if(ppValue == 0) {
|
|
||||||
rc = SXERR_CORRUPT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
*ppValue = &pVm->sExec;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PH7_VM_CONFIG_IO_STREAM: {
|
case PH7_VM_CONFIG_IO_STREAM: {
|
||||||
/* Register an IO stream device */
|
/* Register an IO stream device */
|
||||||
const ph7_io_stream *pStream = va_arg(ap, const ph7_io_stream *);
|
const ph7_io_stream *pStream = va_arg(ap, const ph7_io_stream *);
|
||||||
|
@ -5478,6 +5463,7 @@ PH7_PRIVATE sxi32 PH7_VmByteCodeExec(ph7_vm *pVm) {
|
||||||
ph7_class *pClass;
|
ph7_class *pClass;
|
||||||
ph7_class_instance *pInstance;
|
ph7_class_instance *pInstance;
|
||||||
ph7_class_method *pMethod;
|
ph7_class_method *pMethod;
|
||||||
|
ph7_value pResult;
|
||||||
/* Make sure we are ready to execute this program */
|
/* Make sure we are ready to execute this program */
|
||||||
if(pVm->nMagic != PH7_VM_RUN) {
|
if(pVm->nMagic != PH7_VM_RUN) {
|
||||||
return pVm->nMagic == PH7_VM_EXEC ? SXERR_LOCKED /* Locked VM */ : SXERR_CORRUPT; /* Stale VM */
|
return pVm->nMagic == PH7_VM_EXEC ? SXERR_LOCKED /* Locked VM */ : SXERR_CORRUPT; /* Stale VM */
|
||||||
|
@ -5485,7 +5471,7 @@ PH7_PRIVATE sxi32 PH7_VmByteCodeExec(ph7_vm *pVm) {
|
||||||
/* Set the execution magic number */
|
/* Set the execution magic number */
|
||||||
pVm->nMagic = PH7_VM_EXEC;
|
pVm->nMagic = PH7_VM_EXEC;
|
||||||
/* Execute the byte code */
|
/* Execute the byte code */
|
||||||
VmByteCodeExec(&(*pVm), (VmInstr *)SySetBasePtr(pVm->pByteContainer), pVm->aOps, -1, &pVm->sExec, 0, FALSE);
|
VmByteCodeExec(&(*pVm), (VmInstr *)SySetBasePtr(pVm->pByteContainer), pVm->aOps, -1, 0, 0, FALSE);
|
||||||
/* Extract and instantiate the entry point */
|
/* Extract and instantiate the entry point */
|
||||||
pClass = PH7_VmExtractClass(&(*pVm), "Program", 7, TRUE /* Only loadable class but not 'interface' or 'virtual' class*/, 0);
|
pClass = PH7_VmExtractClass(&(*pVm), "Program", 7, TRUE /* Only loadable class but not 'interface' or 'virtual' class*/, 0);
|
||||||
if(!pClass) {
|
if(!pClass) {
|
||||||
|
@ -5506,7 +5492,10 @@ PH7_PRIVATE sxi32 PH7_VmByteCodeExec(ph7_vm *pVm) {
|
||||||
if(!pMethod) {
|
if(!pMethod) {
|
||||||
VmErrorFormat(&(*pVm), PH7_CTX_ERR, "Cannot find a program entry point 'Program::main()'");
|
VmErrorFormat(&(*pVm), PH7_CTX_ERR, "Cannot find a program entry point 'Program::main()'");
|
||||||
}
|
}
|
||||||
PH7_VmCallClassMethod(&(*pVm), pInstance, pMethod, 0, 0, 0);
|
PH7_VmCallClassMethod(&(*pVm), pInstance, pMethod, &pResult, 0, 0);
|
||||||
|
if(!pVm->iExitStatus) {
|
||||||
|
pVm->iExitStatus = ph7_value_to_int(&pResult);
|
||||||
|
}
|
||||||
/* Invoke any shutdown callbacks */
|
/* Invoke any shutdown callbacks */
|
||||||
VmInvokeShutdownCallbacks(&(*pVm));
|
VmInvokeShutdownCallbacks(&(*pVm));
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1228,7 +1228,6 @@ struct ph7_vm {
|
||||||
SySet aException; /* Stack of loaded exception */
|
SySet aException; /* Stack of loaded exception */
|
||||||
SySet aIOstream; /* Installed IO stream container */
|
SySet aIOstream; /* Installed IO stream container */
|
||||||
const ph7_io_stream *pDefStream; /* Default IO stream [i.e: typically this is the 'file://' stream] */
|
const ph7_io_stream *pDefStream; /* Default IO stream [i.e: typically this is the 'file://' stream] */
|
||||||
ph7_value sExec; /* Compiled script return value [Can be extracted via the PH7_VM_CONFIG_EXEC_VALUE directive]*/
|
|
||||||
ph7_value aExceptionCB[2]; /* Installed exception handler callbacks via [set_exception_handler()] */
|
ph7_value aExceptionCB[2]; /* Installed exception handler callbacks via [set_exception_handler()] */
|
||||||
ph7_value aErrCB[2]; /* Installed error handler callback via [set_error_handler()] */
|
ph7_value aErrCB[2]; /* Installed error handler callback via [set_error_handler()] */
|
||||||
void *pStdin; /* STDIN IO stream */
|
void *pStdin; /* STDIN IO stream */
|
||||||
|
|
Loading…
Reference in New Issue