1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
|
static int exprEval(Th_Interp *interp, Expr *pExpr){
int rc = TH_OK;
if( pExpr->pOp==0 ){
/* A literal */
rc = thSubstWord(interp, pExpr->zValue, pExpr->nValue);
}else{
int eArgType; /* Actual type of arguments */
/* Argument values */
int iLeft;
int iRight;
double fLeft;
double fRight;
|
|
|
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
|
static int exprEval(Th_Interp *interp, Expr *pExpr){
int rc = TH_OK;
if( pExpr->pOp==0 ){
/* A literal */
rc = thSubstWord(interp, pExpr->zValue, pExpr->nValue);
}else{
int eArgType = 0; /* Actual type of arguments */
/* Argument values */
int iLeft;
int iRight;
double fLeft;
double fRight;
|
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
|
if( rc==TH_OK && zRight ){
rc = Th_ToInt(interp, zRight, nRight, &iRight);
}
}
}
if( rc==TH_OK && eArgType==ARG_INTEGER ){
int iRes;
switch( pExpr->pOp->eOp ) {
case OP_MULTIPLY: iRes = iLeft*iRight; break;
case OP_DIVIDE: iRes = iLeft/iRight; break;
case OP_MODULUS: iRes = iLeft%iRight; break;
case OP_ADD: iRes = iLeft+iRight; break;
case OP_SUBTRACT: iRes = iLeft-iRight; break;
case OP_LEFTSHIFT: iRes = iLeft<<iRight; break;
|
|
|
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
|
if( rc==TH_OK && zRight ){
rc = Th_ToInt(interp, zRight, nRight, &iRight);
}
}
}
if( rc==TH_OK && eArgType==ARG_INTEGER ){
int iRes = 0;
switch( pExpr->pOp->eOp ) {
case OP_MULTIPLY: iRes = iLeft*iRight; break;
case OP_DIVIDE: iRes = iLeft/iRight; break;
case OP_MODULUS: iRes = iLeft%iRight; break;
case OP_ADD: iRes = iLeft+iRight; break;
case OP_SUBTRACT: iRes = iLeft-iRight; break;
case OP_LEFTSHIFT: iRes = iLeft<<iRight; break;
|