diff --git a/lib/js/runtime.sx b/lib/js/runtime.sx index e1021cc2..0d754a0b 100644 --- a/lib/js/runtime.sx +++ b/lib/js/runtime.sx @@ -2480,7 +2480,49 @@ ((n (js-to-number (first args)))) (js-math-hypot-loop (rest args) (+ acc (* n n))))))) -(define Math {:random js-math-random :trunc js-math-trunc :LN10 2.30259 :SQRT1_2 0.707107 :floor js-math-floor :PI 3.14159 :sqrt js-math-sqrt :hypot js-math-hypot :LOG2E 1.4427 :round js-math-round :ceil js-math-ceil :abs js-math-abs :pow js-math-pow :max js-math-max :LOG10E 0.434294 :SQRT2 1.41421 :cbrt js-math-cbrt :min js-math-min :sign js-math-sign :E 2.71828 :LN2 0.693147}) +(begin + (define js-math-sin (fn (x) (sin (js-to-number x)))) + (define js-math-cos (fn (x) (cos (js-to-number x)))) + (define js-math-tan (fn (x) (tan (js-to-number x)))) + (define js-math-asin (fn (x) (asin (js-to-number x)))) + (define js-math-acos (fn (x) (acos (js-to-number x)))) + (define js-math-atan (fn (x) (atan (js-to-number x)))) + (define + js-math-atan2 + (fn (y x) (atan2 (js-to-number y) (js-to-number x)))) + (define js-math-sinh (fn (x) (sinh (js-to-number x)))) + (define js-math-cosh (fn (x) (cosh (js-to-number x)))) + (define js-math-tanh (fn (x) (tanh (js-to-number x)))) + (define js-math-asinh (fn (x) (asinh (js-to-number x)))) + (define js-math-acosh (fn (x) (acosh (js-to-number x)))) + (define js-math-atanh (fn (x) (atanh (js-to-number x)))) + (define js-math-exp (fn (x) (exp (js-to-number x)))) + (define js-math-log (fn (x) (log (js-to-number x)))) + (define js-math-log2 (fn (x) (log2 (js-to-number x)))) + (define js-math-log10 (fn (x) (log10 (js-to-number x)))) + (define js-math-expm1 (fn (x) (expm1 (js-to-number x)))) + (define js-math-log1p (fn (x) (log1p (js-to-number x)))) + (define + js-math-clz32 + (fn + (&rest args) + (let + ((x (if (empty? args) 0 (js-to-number (nth args 0))))) + (let + ((n (modulo (floor x) 4294967296))) + (if (= n 0) 32 (- 31 (floor (log2 n)))))))) + (define + js-math-imul + (fn + (a b) + (let + ((a32 (modulo (floor (js-to-number a)) 4294967296)) + (b32 (modulo (floor (js-to-number b)) 4294967296))) + (let + ((result (modulo (* a32 b32) 4294967296))) + (if (>= result 2147483648) (- result 4294967296) result))))) + (define js-math-fround (fn (x) (js-to-number x))) + (define Math {:trunc js-math-trunc :expm1 js-math-expm1 :atan2 js-math-atan2 :PI 3.14159 :asinh js-math-asinh :acosh js-math-acosh :hypot js-math-hypot :LOG2E 1.4427 :atanh js-math-atanh :ceil js-math-ceil :pow js-math-pow :sin js-math-sin :max js-math-max :log2 js-math-log2 :SQRT2 1.41421 :cbrt js-math-cbrt :log1p js-math-log1p :fround js-math-fround :E 2.71828 :sinh js-math-sinh :random js-math-random :LN10 2.30259 :SQRT1_2 0.707107 :asin js-math-asin :clz32 js-math-clz32 :floor js-math-floor :exp js-math-exp :tan js-math-tan :sqrt js-math-sqrt :cosh js-math-cosh :log js-math-log :round js-math-round :abs js-math-abs :LOG10E 0.434294 :tanh js-math-tanh :acos js-math-acos :log10 js-math-log10 :min js-math-min :sign js-math-sign :LN2 0.693147 :cos js-math-cos :imul js-math-imul :atan js-math-atan})) (define js-number-is-finite