* compiler/vmhooks: add getVar to allow vmops with var params * addFloat vmops with var param * cgen now renders float32 literals in c backend using roundtrip float to string
This commit is contained in:
parent
a8b3e7c059
commit
cf0cf32d27
21 changed files with 286 additions and 199 deletions
|
|
@ -496,23 +496,6 @@ proc negInt(a: int): int {.compilerproc.} =
|
|||
proc negInt64(a: int64): int64 {.compilerproc.} =
|
||||
result = a*(-1)
|
||||
|
||||
proc nimFloatToString(a: float): cstring {.compilerproc.} =
|
||||
## ensures the result doesn't print like an integer, i.e. return 2.0, not 2
|
||||
# print `-0.0` properly
|
||||
asm """
|
||||
function nimOnlyDigitsOrMinus(n) {
|
||||
return n.toString().match(/^-?\d+$/);
|
||||
}
|
||||
if (Number.isSafeInteger(`a`))
|
||||
`result` = `a` === 0 && 1 / `a` < 0 ? "-0.0" : `a`+".0"
|
||||
else {
|
||||
`result` = `a`+""
|
||||
if(nimOnlyDigitsOrMinus(`result`)){
|
||||
`result` = `a`+".0"
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
proc absInt(a: int): int {.compilerproc.} =
|
||||
result = if a < 0: a*(-1) else: a
|
||||
|
||||
|
|
@ -703,6 +686,7 @@ proc addChar(x: string, c: char) {.compilerproc, asmNoStackFrame.} =
|
|||
{.pop.}
|
||||
|
||||
proc tenToThePowerOf(b: int): BiggestFloat =
|
||||
# xxx deadcode
|
||||
var b = b
|
||||
var a = 10.0
|
||||
result = 1.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue