make mod on floats available in the VM (#9591)

* make `mod` on floats available in the VM
* add testcase
* removed no longer needed imports
This commit is contained in:
skilchen 2018-11-05 09:36:28 +01:00 • committed by Andreas Rumpf
commit da178e4090
2 changed files with 135 additions and 1 deletions

View file

@ -11,7 +11,7 @@
#import vmdeps, vm
from math import sqrt, ln, log10, log2, exp, round, arccos, arcsin,
arctan, arctan2, cos, cosh, hypot, sinh, sin, tan, tanh, pow, trunc,
floor, ceil, fmod
floor, ceil, `mod`, fmod
from os import getEnv, existsEnv, dirExists, fileExists, putEnv, walkDir
@ -107,6 +107,10 @@ proc registerAdditionalOps*(c: PCtx) =
wrap1f_math(ceil)
wrap2f_math(fmod)
proc `mod Wrapper`(a: VmArgs) {.nimcall.} =
setResult(a, `mod`(getFloat(a, 0), getFloat(a, 1)))
registerCallback(c, "stdlib.math.mod", `mod Wrapper`)
when defined(nimcore):
wrap2s(getEnv, ospathsop)
wrap1s(existsEnv, ospathsop)