This is a necessary step, to allow passing integer numbers. Otherwise, every float variable would need a floating point value. In other words, "float $x = 5" is allowed construct. Without this simple change, only accepted construction was "float $x = 5.0".
This commit is contained in:
parent
58103ea5fe
commit
82998ffd0f
10
engine/vm.c
10
engine/vm.c
|
@ -4983,12 +4983,16 @@ static sxi32 VmByteCodeExec(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(aFormalArg[n].nType != MEMOBJ_MIXED && ((pArg->iFlags & aFormalArg[n].nType) == 0)) {
|
} else if(aFormalArg[n].nType != MEMOBJ_MIXED && ((pArg->iFlags & aFormalArg[n].nType) == 0)) {
|
||||||
|
if(aFormalArg[n].nType == MEMOBJ_REAL && (pArg->iFlags & MEMOBJ_INT)) {
|
||||||
|
/* Silently typecast integer value to float */
|
||||||
ProcMemObjCast xCast = PH7_MemObjCastMethod(aFormalArg[n].nType);
|
ProcMemObjCast xCast = PH7_MemObjCastMethod(aFormalArg[n].nType);
|
||||||
xCast(pArg);
|
xCast(pArg);
|
||||||
|
} else {
|
||||||
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
|
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
|
||||||
"Argument %u of '%z()' does not match the data type", n + 1, &pVmFunc->sName);
|
"Argument %u of '%z()' does not match the data type", n + 1, &pVmFunc->sName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(aFormalArg[n].iFlags & VM_FUNC_ARG_BY_REF) {
|
if(aFormalArg[n].iFlags & VM_FUNC_ARG_BY_REF) {
|
||||||
/* Pass by reference */
|
/* Pass by reference */
|
||||||
if(pArg->nIdx == SXU32_HIGH) {
|
if(pArg->nIdx == SXU32_HIGH) {
|
||||||
|
@ -5070,9 +5074,15 @@ static sxi32 VmByteCodeExec(
|
||||||
goto Abort;
|
goto Abort;
|
||||||
}
|
}
|
||||||
if(aFormalArg[n].nType != MEMOBJ_MIXED && aFormalArg[n].nType > 0 && ((pObj->iFlags & aFormalArg[n].nType) == 0)) {
|
if(aFormalArg[n].nType != MEMOBJ_MIXED && aFormalArg[n].nType > 0 && ((pObj->iFlags & aFormalArg[n].nType) == 0)) {
|
||||||
|
if(aFormalArg[n].nType == MEMOBJ_REAL && (pObj->iFlags & MEMOBJ_INT)) {
|
||||||
|
/* Silently typecast integer value to float */
|
||||||
|
ProcMemObjCast xCast = PH7_MemObjCastMethod(aFormalArg[n].nType);
|
||||||
|
xCast(pObj);
|
||||||
|
} else {
|
||||||
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
|
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR,
|
||||||
"Default value for argument %u of '%z()' does not match the data type", n + 1, &pVmFunc->sName);
|
"Default value for argument %u of '%z()' does not match the data type", n + 1, &pVmFunc->sName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Insert argument index */
|
/* Insert argument index */
|
||||||
sArg.nIdx = pObj->nIdx;
|
sArg.nIdx = pObj->nIdx;
|
||||||
sArg.pUserData = 0;
|
sArg.pUserData = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user