Browse Source

Don't try to get an integer representation of float.

release/v0.1
Rafal Kupiec 3 years ago
parent
commit
af1d59dab4
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
4 changed files with 0 additions and 57 deletions
  1. +0
    -2
      engine/api.c
  2. +0
    -36
      engine/memobj.c
  3. +0
    -18
      engine/vm.c
  4. +0
    -1
      include/ph7int.h

+ 0
- 2
engine/api.c View File

@ -1794,8 +1794,6 @@ int ph7_value_double(ph7_value *pVal, double Value) {
PH7_MemObjRelease(pVal);
pVal->rVal = (ph7_real)Value;
MemObjSetType(pVal, MEMOBJ_REAL);
/* Try to get an integer representation also */
PH7_MemObjTryInteger(pVal);
return PH7_OK;
}
/*


+ 0
- 36
engine/memobj.c View File

@ -329,29 +329,6 @@ static sxi32 MemObjBooleanValue(ph7_value *pObj) {
/* NOT REACHED */
return 0;
}
/*
* If the ph7_value is of type real,try to make it an integer also.
*/
static sxi32 MemObjTryIntger(ph7_value *pObj) {
pObj->x.iVal = MemObjRealToInt(&(*pObj));
/* Only mark the value as an integer if
**
** (1) the round-trip conversion real->int->real is a no-op, and
** (2) The integer is neither the largest nor the smallest
** possible integer
**
** The second and third terms in the following conditional enforces
** the second condition under the assumption that addition overflow causes
** values to wrap around. On x86 hardware, the third term is always
** true and could be omitted. But we leave it in because other
** architectures might behave differently.
*/
if(pObj->rVal == (ph7_real)pObj->x.iVal && pObj->x.iVal > SMALLEST_INT64
&& pObj->x.iVal < LARGEST_INT64) {
pObj->iFlags |= MEMOBJ_INT;
}
return SXRET_OK;
}
/*
* Convert a ph7_value to type integer.Invalidate any prior representations.
*/
@ -653,17 +630,6 @@ PH7_PRIVATE sxi32 PH7_MemObjToNumeric(ph7_value *pObj) {
}
return SXRET_OK;
}
/*
* Try a get an integer representation of the given ph7_value.
* If the ph7_value is not of type real,this function is a no-op.
*/
PH7_PRIVATE sxi32 PH7_MemObjTryInteger(ph7_value *pObj) {
if(pObj->iFlags & MEMOBJ_REAL) {
/* Work only with reals */
MemObjTryIntger(&(*pObj));
}
return SXRET_OK;
}
/*
* Initialize a ph7_value to the null type.
*/
@ -1075,8 +1041,6 @@ PH7_PRIVATE sxi32 PH7_MemObjAdd(ph7_value *pObj1, ph7_value *pObj2, int bAddStor
b = pObj2->rVal;
pObj1->rVal = a + b;
MemObjSetType(pObj1, MEMOBJ_REAL);
/* Try to get an integer representation also */
MemObjTryIntger(&(*pObj1));
} else {
/* Integer arithmetic */
sxi64 a, b;


+ 0
- 18
engine/vm.c View File

@ -2851,8 +2851,6 @@ static sxi32 VmByteCodeExec(
PH7_MemObjToNumeric(pObj);
if(pObj->iFlags & MEMOBJ_REAL) {
pObj->rVal++;
/* Try to get an integer representation */
PH7_MemObjTryInteger(pTos);
} else {
pObj->x.iVal++;
MemObjSetType(pTos, MEMOBJ_INT);
@ -2869,8 +2867,6 @@ static sxi32 VmByteCodeExec(
/* Pre-increment */
if(pTos->iFlags & MEMOBJ_REAL) {
pTos->rVal++;
/* Try to get an integer representation */
PH7_MemObjTryInteger(pTos);
} else {
pTos->x.iVal++;
MemObjSetType(pTos, MEMOBJ_INT);
@ -2902,8 +2898,6 @@ static sxi32 VmByteCodeExec(
PH7_MemObjToNumeric(pObj);
if(pObj->iFlags & MEMOBJ_REAL) {
pObj->rVal--;
/* Try to get an integer representation */
PH7_MemObjTryInteger(pTos);
} else {
pObj->x.iVal--;
MemObjSetType(pTos, MEMOBJ_INT);
@ -2918,8 +2912,6 @@ static sxi32 VmByteCodeExec(
/* Pre-decrement */
if(pTos->iFlags & MEMOBJ_REAL) {
pTos->rVal--;
/* Try to get an integer representation */
PH7_MemObjTryInteger(pTos);
} else {
pTos->x.iVal--;
MemObjSetType(pTos, MEMOBJ_INT);
@ -3037,8 +3029,6 @@ static sxi32 VmByteCodeExec(
/* Push the result */
pNos->rVal = r;
MemObjSetType(pNos, MEMOBJ_REAL);
/* Try to get an integer representation */
PH7_MemObjTryInteger(pNos);
} else {
/* Integer arithmetic */
sxi64 a, b, r;
@ -3169,8 +3159,6 @@ static sxi32 VmByteCodeExec(
/* Push the result */
pNos->rVal = r;
MemObjSetType(pNos, MEMOBJ_REAL);
/* Try to get an integer representation */
PH7_MemObjTryInteger(pNos);
} else {
/* Integer arithmetic */
sxi64 a, b, r;
@ -3213,8 +3201,6 @@ static sxi32 VmByteCodeExec(
/* Push the result */
pNos->rVal = r;
MemObjSetType(pNos, MEMOBJ_REAL);
/* Try to get an integer representation */
PH7_MemObjTryInteger(pNos);
} else {
/* Integer arithmetic */
sxi64 a, b, r;
@ -3355,8 +3341,6 @@ static sxi32 VmByteCodeExec(
/* Push the result */
pNos->rVal = r;
MemObjSetType(pNos, MEMOBJ_REAL);
/* Try to get an integer representation */
PH7_MemObjTryInteger(pNos);
}
VmPopOperand(&pTos, 1);
break;
@ -3398,8 +3382,6 @@ static sxi32 VmByteCodeExec(
/* Push the result */
pNos->rVal = r;
MemObjSetType(pNos, MEMOBJ_REAL);
/* Try to get an integer representation */
PH7_MemObjTryInteger(pNos);
}
if(pTos->nIdx == SXU32_HIGH) {
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute");


+ 0
- 1
include/ph7int.h View File

@ -1642,7 +1642,6 @@ PH7_PRIVATE sxi32 PH7_MemObjStore(ph7_value *pSrc, ph7_value *pDest);
PH7_PRIVATE sxi32 PH7_MemObjLoad(ph7_value *pSrc, ph7_value *pDest);
PH7_PRIVATE sxi32 PH7_MemObjRelease(ph7_value *pObj);
PH7_PRIVATE sxi32 PH7_MemObjToNumeric(ph7_value *pObj);
PH7_PRIVATE sxi32 PH7_MemObjTryInteger(ph7_value *pObj);
PH7_PRIVATE ProcMemObjCast PH7_MemObjCastMethod(sxi32 iFlags);
PH7_PRIVATE sxi32 PH7_MemObjIsNumeric(ph7_value *pObj);
PH7_PRIVATE sxi32 PH7_MemObjIsEmpty(ph7_value *pObj);


Loading…
Cancel
Save