This commit is contained in:
@@ -42,7 +42,7 @@ static struct Global_Data {
|
||||
ph7 *pEngines; /* List of active engine */
|
||||
sxu32 nMagic; /* Sanity check against library misuse */
|
||||
} sMPGlobal = {
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, {0}},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, {0}},
|
||||
#if defined(PH7_ENABLE_THREADS)
|
||||
0,
|
||||
0,
|
||||
@@ -1829,14 +1829,13 @@ int ph7_value_string(ph7_value *pVal, const char *zString, int nLen) {
|
||||
*/
|
||||
int ph7_value_string_format(ph7_value *pVal, const char *zFormat, ...) {
|
||||
va_list ap;
|
||||
int rc;
|
||||
if((pVal->nType & MEMOBJ_STRING) == 0) {
|
||||
/* Invalidate any prior representation */
|
||||
PH7_MemObjRelease(pVal);
|
||||
MemObjSetType(pVal, MEMOBJ_STRING);
|
||||
}
|
||||
va_start(ap, zFormat);
|
||||
rc = SyBlobFormatAp(&pVal->sBlob, zFormat, ap);
|
||||
SyBlobFormatAp(&pVal->sBlob, zFormat, ap);
|
||||
va_end(ap);
|
||||
return PH7_OK;
|
||||
}
|
||||
|
@@ -3279,7 +3279,6 @@ PH7_PRIVATE sxi32 PH7_InputFormat(
|
||||
ph7_value *pArg; /* Current processed argument */
|
||||
ph7_int64 iVal;
|
||||
int precision; /* Precision of the current field */
|
||||
char *zExtra;
|
||||
int c, rc, n;
|
||||
int length; /* Length of the field */
|
||||
int prefix;
|
||||
@@ -3404,7 +3403,6 @@ PH7_PRIVATE sxi32 PH7_InputFormat(
|
||||
}
|
||||
zBuf = zWorker; /* Point to the working buffer */
|
||||
length = 0;
|
||||
zExtra = 0;
|
||||
/*
|
||||
** At this point, variables are initialized as follows:
|
||||
**
|
||||
|
@@ -902,7 +902,7 @@ PH7_PRIVATE sxi32 PH7_CompileClosure(ph7_gen_state *pGen, sxi32 iCompileFlag) {
|
||||
sxu32 nIdx;
|
||||
sxu32 nLen;
|
||||
sxi32 rc;
|
||||
sxu32 nType;
|
||||
sxu32 nType = 0;
|
||||
SXUNUSED(iCompileFlag);
|
||||
sxu32 nKey = (sxu32)(SX_PTR_TO_INT(pGen->pIn->pUserData));
|
||||
if(nKey & PH7_KEYWORD_BOOL) {
|
||||
@@ -1484,7 +1484,7 @@ static sxi32 PH7_CompileLabel(ph7_gen_state *pGen)
|
||||
sLabel.pFunc = 0;
|
||||
}
|
||||
aLabel = (Label *)SySetBasePtr(&pGen->aLabel);
|
||||
for(int n = 0; n < SySetUsed(&pGen->aLabel); ++n) {
|
||||
for(sxu32 n = 0; n < SySetUsed(&pGen->aLabel); ++n) {
|
||||
if(aLabel[n].pFunc == sLabel.pFunc && SyStringCmp(&aLabel[n].sName, &sLabel.sName, SyMemcmp) == 0) {
|
||||
PH7_GenCompileError(&(*pGen), E_ERROR, pGen->pIn->nLine, "Duplicate label '%z'", &sLabel.sName);
|
||||
}
|
||||
@@ -3599,7 +3599,7 @@ static sxi32 PH7_CompileClassInterface(ph7_gen_state *pGen) {
|
||||
"Unexpected token '%z', expecting data type for method signature inside interface '%z'",
|
||||
&pGen->pIn->sData, pName);
|
||||
}
|
||||
sxu32 nType;
|
||||
sxu32 nType = 0;
|
||||
sxu32 nKey = (sxu32)(SX_PTR_TO_INT(pGen->pIn->pUserData));
|
||||
if(nKey & PH7_KEYWORD_BOOL) {
|
||||
nType = MEMOBJ_BOOL;
|
||||
@@ -3894,7 +3894,7 @@ static sxi32 PH7_GenStateCompileClass(ph7_gen_state *pGen, sxi32 iFlags) {
|
||||
"Unexpected token '%z', expecting data type for attribute or method declaration inside class '%z'",
|
||||
&pGen->pIn->sData, pName);
|
||||
}
|
||||
sxu32 nType;
|
||||
sxu32 nType = 0;
|
||||
sxu32 nKey = (sxu32)(SX_PTR_TO_INT(pGen->pIn->pUserData));
|
||||
if(nKey & PH7_KEYWORD_BOOL) {
|
||||
nType = MEMOBJ_BOOL;
|
||||
@@ -4080,7 +4080,6 @@ static sxi32 PH7_CompileThrow(ph7_gen_state *pGen) {
|
||||
* an object containing the exception information.
|
||||
*/
|
||||
static sxi32 PH7_CompileCatch(ph7_gen_state *pGen, ph7_exception *pException) {
|
||||
sxu32 nLine = pGen->pIn->nLine;
|
||||
ph7_exception_block sCatch;
|
||||
SySet *pInstrContainer;
|
||||
GenBlock *pCatch;
|
||||
@@ -4096,8 +4095,12 @@ static sxi32 PH7_CompileCatch(ph7_gen_state *pGen, ph7_exception *pException) {
|
||||
if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & PH7_TK_LPAREN) == 0 /*(*/ ||
|
||||
&pGen->pIn[1] >= pGen->pEnd || (pGen->pIn[1].nType & (PH7_TK_ID | PH7_TK_KEYWORD)) == 0) {
|
||||
/* Unexpected token, break immediately */
|
||||
pToken = pGen->pIn;
|
||||
if(pToken >= pGen->pEnd) {
|
||||
pToken--;
|
||||
}
|
||||
PH7_GenCompileError(pGen, E_ERROR, pToken->nLine,
|
||||
"Catch: Unexpected token '%z',excpecting class name", &pToken->sData);
|
||||
"Catch: Unexpected token '%z',expecting class name", &pToken->sData);
|
||||
}
|
||||
/* Extract the exception class */
|
||||
pGen->pIn++; /* Jump the left parenthesis '(' */
|
||||
@@ -4112,6 +4115,10 @@ static sxi32 PH7_CompileCatch(ph7_gen_state *pGen, ph7_exception *pException) {
|
||||
if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & PH7_TK_DOLLAR) == 0 /*$*/ ||
|
||||
&pGen->pIn[1] >= pGen->pEnd || (pGen->pIn[1].nType & (PH7_TK_ID | PH7_TK_KEYWORD)) == 0) {
|
||||
/* Unexpected token, break immediately */
|
||||
pToken = pGen->pIn;
|
||||
if(pToken >= pGen->pEnd) {
|
||||
pToken--;
|
||||
}
|
||||
PH7_GenCompileError(pGen, E_ERROR, pToken->nLine,
|
||||
"Catch: Unexpected token '%z',expecting variable name", &pToken->sData);
|
||||
}
|
||||
@@ -4126,6 +4133,10 @@ static sxi32 PH7_CompileCatch(ph7_gen_state *pGen, ph7_exception *pException) {
|
||||
pGen->pIn++;
|
||||
if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & PH7_TK_RPAREN) == 0 /*)*/) {
|
||||
/* Unexpected token, break immediately */
|
||||
pToken = pGen->pIn;
|
||||
if(pToken >= pGen->pEnd) {
|
||||
pToken--;
|
||||
}
|
||||
PH7_GenCompileError(pGen, E_ERROR, pToken->nLine,
|
||||
"Catch: Unexpected token '%z',expecting right parenthesis ')'", &pToken->sData);
|
||||
}
|
||||
@@ -4156,7 +4167,7 @@ static sxi32 PH7_CompileCatch(ph7_gen_state *pGen, ph7_exception *pException) {
|
||||
}
|
||||
return SXRET_OK;
|
||||
Mem:
|
||||
PH7_GenCompileError(&(*pGen), E_ERROR, nLine, "PH7 engine is running out-of-memory");
|
||||
PH7_GenCompileError(&(*pGen), E_ERROR, pGen->pIn->nLine, "PH7 engine is running out-of-memory");
|
||||
}
|
||||
/*
|
||||
* Compile a 'finally' block.
|
||||
|
@@ -2533,6 +2533,7 @@ static sxi32 VmByteCodeExec(
|
||||
if(pMap == 0) {
|
||||
PH7_VmMemoryError(&(*pVm));
|
||||
}
|
||||
nType = 0;
|
||||
if(pInstr->iP1 > 0) {
|
||||
ph7_value *pEntry = &pTos[-pInstr->iP1 + 1]; /* Point to the first entry */
|
||||
nType = pEntry[1].nType; /* Save the type of value */
|
||||
@@ -3302,6 +3303,7 @@ static sxi32 VmByteCodeExec(
|
||||
/* Perform the requested operation */
|
||||
a = pNos->x.iVal;
|
||||
b = pTos->x.iVal;
|
||||
r = 0;
|
||||
if(b == 0) {
|
||||
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd%%0", a);
|
||||
} else {
|
||||
@@ -3341,6 +3343,7 @@ static sxi32 VmByteCodeExec(
|
||||
/* Perform the requested operation */
|
||||
a = pTos->x.iVal;
|
||||
b = pNos->x.iVal;
|
||||
r = 0;
|
||||
if(b == 0) {
|
||||
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd%%0", a);
|
||||
} else {
|
||||
@@ -4633,7 +4636,6 @@ static sxi32 VmByteCodeExec(
|
||||
pSelf = 0;
|
||||
pClass = 0;
|
||||
if(pVmFunc->iFlags & VM_FUNC_CLASS_METHOD) {
|
||||
ph7_class_method *pMeth;
|
||||
/* Class method call */
|
||||
ph7_value *pTarget = &pTos[-1];
|
||||
if(pTarget >= pStack && (pTarget->nType & (MEMOBJ_STRING | MEMOBJ_OBJ | MEMOBJ_NULL))) {
|
||||
@@ -8084,7 +8086,7 @@ static int vm_builtin_debug_backtrace(ph7_context *pCtx, int nArg, ph7_value **a
|
||||
ph7_value_reset_string_cursor(pValue);
|
||||
/* Extract closure/method arguments */
|
||||
aSlot = (VmSlot *)SySetBasePtr(pTrace->pArg);
|
||||
for(int n = 0; n < SySetUsed(pTrace->pArg) ; n++) {
|
||||
for(sxu32 n = 0; n < SySetUsed(pTrace->pArg) ; n++) {
|
||||
ph7_value *pObj = (ph7_value *)SySetAt(&pCtx->pVm->aMemObj, aSlot[n].nIdx);
|
||||
if(pObj) {
|
||||
ph7_array_add_elem(pArg, 0, pObj);
|
||||
|
Reference in New Issue
Block a user