diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/host/js.lux | 13 | ||||
-rw-r--r-- | stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/stdlib/source/lux/host/js.lux b/stdlib/source/lux/host/js.lux index bb52784a1..7fa3b7123 100644 --- a/stdlib/source/lux/host/js.lux +++ b/stdlib/source/lux/host/js.lux @@ -246,10 +246,15 @@ [negate "-"] ) - (def: #export (i32 value) - {#.doc "A 32-bit integer expression."} - (-> Int Computation) - (:abstraction (..argument (format (%i value) "|0")))) + (do-template [<name> <input> <format>] + [(def: #export (<name> value) + {#.doc "A 32-bit integer expression."} + (-> <input> Computation) + (:abstraction (..argument (format (<format> value) "|0"))))] + + [to-i32 Expression :representation] + [i32 Int %i] + ) (def: #export (? test then else) (-> Expression Expression Expression Computation) diff --git a/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux b/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux index b3ff414b2..25f24cc98 100644 --- a/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux +++ b/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux @@ -359,8 +359,8 @@ (_.return i64//max)] [(|> value (_.< (_.i32 +0))) (_.return (|> value _.negate i64//from-number i64//negate))]) - (_.return (i64//new (_./ i64//2^32 value) - (_.% i64//2^32 value))))) + (_.return (i64//new (|> value (_./ i64//2^32) _.to-i32) + (|> value (_.% i64//2^32) _.to-i32))))) (def: (cap-shift! shift) (-> Var Statement) |