parent
397246d2f1
commit
e7b78be8e5
38
engine/vm.c
38
engine/vm.c
|
@ -8411,7 +8411,6 @@ static int vm_builtin_random_int(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
} else if(iMax > 0) {
|
} else if(iMax > 0) {
|
||||||
iNum %= iMax;
|
iNum %= iMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
ph7_result_int64(pCtx, (ph7_int64)iNum);
|
ph7_result_int64(pCtx, (ph7_int64)iNum);
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
|
@ -9427,18 +9426,22 @@ static int vm_builtin_debug_backtrace(ph7_context *pCtx, int nArg, ph7_value **a
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Dump running function name and it's arguments */
|
/* Dump running function name and it's arguments */
|
||||||
if(pVm->pFrame->pParent) {
|
while(pVm->pFrame) {
|
||||||
|
ph7_value *pArraySub;
|
||||||
VmFrame *pFrame = pVm->pFrame;
|
VmFrame *pFrame = pVm->pFrame;
|
||||||
ph7_vm_func *pFunc;
|
ph7_vm_func *pFunc;
|
||||||
ph7_value *pArg;
|
ph7_value *pArg;
|
||||||
while(pFrame->pParent && (pFrame->iFlags & VM_FRAME_EXCEPTION)) {
|
|
||||||
/* Safely ignore the exception frame */
|
|
||||||
pFrame = pFrame->pParent;
|
|
||||||
}
|
|
||||||
pFunc = (ph7_vm_func *)pFrame->pUserData;
|
pFunc = (ph7_vm_func *)pFrame->pUserData;
|
||||||
if(pFrame->pParent && pFunc) {
|
if(!pFunc || (pFrame->iFlags & VM_FRAME_EXCEPTION)) {
|
||||||
|
goto rollFrame;
|
||||||
|
}
|
||||||
|
pArraySub = ph7_context_new_array(pCtx);
|
||||||
|
if(!pArraySub) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(pFrame->pParent) {
|
||||||
ph7_value_string(pValue, pFunc->sName.zString, (int)pFunc->sName.nByte);
|
ph7_value_string(pValue, pFunc->sName.zString, (int)pFunc->sName.nByte);
|
||||||
ph7_array_add_strkey_elem(pArray, "function", pValue);
|
ph7_array_add_strkey_elem(pArraySub, "function", pValue);
|
||||||
ph7_value_reset_string_cursor(pValue);
|
ph7_value_reset_string_cursor(pValue);
|
||||||
}
|
}
|
||||||
/* Function arguments */
|
/* Function arguments */
|
||||||
|
@ -9456,31 +9459,30 @@ static int vm_builtin_debug_backtrace(ph7_context *pCtx, int nArg, ph7_value **a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Save the array */
|
/* Save the array */
|
||||||
ph7_array_add_strkey_elem(pArray, "args", pArg);
|
ph7_array_add_strkey_elem(pArraySub, "args", pArg);
|
||||||
}
|
}
|
||||||
if(pFunc) {
|
if(pFunc) {
|
||||||
for (sxi32 i = (SySetUsed(pVm->pByteContainer) - 1); i >= 0 ; i--) {
|
SySet *aByteCode = &pFunc->aByteCode;
|
||||||
VmInstr *cInstr = (VmInstr *)SySetAt(pVm->pByteContainer, i);
|
for(sxi32 i = (SySetUsed(aByteCode) - 1); i >= 0 ; i--) {
|
||||||
|
VmInstr *cInstr = (VmInstr *)SySetAt(aByteCode, i);
|
||||||
if(cInstr->iP2) {
|
if(cInstr->iP2) {
|
||||||
iLine = cInstr->iLine;
|
iLine = cInstr->iLine;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(iLine != -1) {
|
if(iLine != -1) {
|
||||||
ph7_value_int(pValue, iLine);
|
ph7_value_int(pValue, iLine);
|
||||||
/* Append the current line (which is always 1 since PH7 does not track
|
/* Append the current line (which is always 1 since PH7 does not track
|
||||||
* line numbers at run-time. )
|
* line numbers at run-time. )
|
||||||
*/
|
*/
|
||||||
ph7_array_add_strkey_elem(pArray, "line", pValue);
|
ph7_array_add_strkey_elem(pArraySub, "line", pValue);
|
||||||
}
|
}
|
||||||
/* Current processed script */
|
/* Current processed script */
|
||||||
pFile = (SyString *)SySetPeek(&pVm->aFiles);
|
pFile = (SyString *)SySetPeek(&pVm->aFiles);
|
||||||
if(pFile) {
|
if(pFile) {
|
||||||
ph7_value_string(pValue, pFile->zString, (int)pFile->nByte);
|
ph7_value_string(pValue, pFile->zString, (int)pFile->nByte);
|
||||||
ph7_array_add_strkey_elem(pArray, "file", pValue);
|
ph7_array_add_strkey_elem(pArraySub, "file", pValue);
|
||||||
ph7_value_reset_string_cursor(pValue);
|
ph7_value_reset_string_cursor(pValue);
|
||||||
}
|
}
|
||||||
/* Top class */
|
/* Top class */
|
||||||
|
@ -9488,7 +9490,11 @@ static int vm_builtin_debug_backtrace(ph7_context *pCtx, int nArg, ph7_value **a
|
||||||
if(pClass) {
|
if(pClass) {
|
||||||
ph7_value_reset_string_cursor(pValue);
|
ph7_value_reset_string_cursor(pValue);
|
||||||
ph7_value_string(pValue, pClass->sName.zString, (int)pClass->sName.nByte);
|
ph7_value_string(pValue, pClass->sName.zString, (int)pClass->sName.nByte);
|
||||||
ph7_array_add_strkey_elem(pArray, "class", pValue);
|
ph7_array_add_strkey_elem(pArraySub, "class", pValue);
|
||||||
|
}
|
||||||
|
ph7_array_add_elem(pArray, 0, pArraySub);
|
||||||
|
rollFrame:
|
||||||
|
pVm->pFrame = pVm->pFrame->pParent;
|
||||||
}
|
}
|
||||||
/* Return the freshly created array */
|
/* Return the freshly created array */
|
||||||
ph7_result_value(pCtx, pArray);
|
ph7_result_value(pCtx, pArray);
|
||||||
|
|
|
@ -500,7 +500,6 @@ static int PH7_builtin_ctype_upper(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
PH7_PRIVATE sxi32 initializeModule(ph7_vm *pVm, ph7_real *ver, SyString *desc) {
|
PH7_PRIVATE sxi32 initializeModule(ph7_vm *pVm, ph7_real *ver, SyString *desc) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
|
|
||||||
desc->zString = MODULE_DESC;
|
desc->zString = MODULE_DESC;
|
||||||
*ver = MODULE_VER;
|
*ver = MODULE_VER;
|
||||||
for(n = 0; n < SX_ARRAYSIZE(ctypeFuncList); ++n) {
|
for(n = 0; n < SX_ARRAYSIZE(ctypeFuncList); ++n) {
|
||||||
|
|
|
@ -16,7 +16,6 @@ int psharp_dummy_function(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
PH7_PRIVATE sxi32 initializeModule(ph7_vm *pVm, ph7_real *ver, SyString *desc) {
|
PH7_PRIVATE sxi32 initializeModule(ph7_vm *pVm, ph7_real *ver, SyString *desc) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
|
|
||||||
desc->zString = MODULE_DESC;
|
desc->zString = MODULE_DESC;
|
||||||
*ver = MODULE_VER;
|
*ver = MODULE_VER;
|
||||||
for(n = 0; n < SX_ARRAYSIZE(dummyConstList); ++n) {
|
for(n = 0; n < SX_ARRAYSIZE(dummyConstList); ++n) {
|
||||||
|
|
|
@ -889,7 +889,6 @@ static int vm_builtin_json_decode(ph7_context *pCtx, int nArg, ph7_value **apArg
|
||||||
PH7_PRIVATE sxi32 initializeModule(ph7_vm *pVm, ph7_real *ver, SyString *desc) {
|
PH7_PRIVATE sxi32 initializeModule(ph7_vm *pVm, ph7_real *ver, SyString *desc) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
|
|
||||||
desc->zString = MODULE_DESC;
|
desc->zString = MODULE_DESC;
|
||||||
*ver = MODULE_VER;
|
*ver = MODULE_VER;
|
||||||
for(n = 0; n < SX_ARRAYSIZE(jsonConstList); ++n) {
|
for(n = 0; n < SX_ARRAYSIZE(jsonConstList); ++n) {
|
||||||
|
|
|
@ -628,7 +628,6 @@ static int PH7_builtin_hypot(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
PH7_PRIVATE sxi32 initializeModule(ph7_vm *pVm, ph7_real *ver, SyString *desc) {
|
PH7_PRIVATE sxi32 initializeModule(ph7_vm *pVm, ph7_real *ver, SyString *desc) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
|
|
||||||
desc->zString = MODULE_DESC;
|
desc->zString = MODULE_DESC;
|
||||||
*ver = MODULE_VER;
|
*ver = MODULE_VER;
|
||||||
for(n = 0; n < SX_ARRAYSIZE(mathConstList); ++n) {
|
for(n = 0; n < SX_ARRAYSIZE(mathConstList); ++n) {
|
||||||
|
|
|
@ -1464,7 +1464,6 @@ static int vm_builtin_xml_error_string(ph7_context *pCtx, int nArg, ph7_value **
|
||||||
PH7_PRIVATE sxi32 initializeModule(ph7_vm *pVm, ph7_real *ver, SyString *desc) {
|
PH7_PRIVATE sxi32 initializeModule(ph7_vm *pVm, ph7_real *ver, SyString *desc) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
|
|
||||||
desc->zString = MODULE_DESC;
|
desc->zString = MODULE_DESC;
|
||||||
*ver = MODULE_VER;
|
*ver = MODULE_VER;
|
||||||
for(n = 0; n < SX_ARRAYSIZE(xmlConstList); ++n) {
|
for(n = 0; n < SX_ARRAYSIZE(xmlConstList); ++n) {
|
||||||
|
|
Loading…
Reference in New Issue