aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2019-03-16 01:44:46 -0400
committerEduardo Julian2019-03-16 01:44:46 -0400
commitc2bc59de623699dcb338e74a822ce02cb8deee19 (patch)
tree4e9e10d8f00c8dc6b9760eaddd54ab906a6bba33 /stdlib/source
parentf9d4d316ef9666f6b122b0eec8180351216e95f8 (diff)
Fixed a bug when creating Lux numbers in JavaScript.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/host/js.lux13
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux4
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)