From c2bc59de623699dcb338e74a822ce02cb8deee19 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 16 Mar 2019 01:44:46 -0400 Subject: Fixed a bug when creating Lux numbers in JavaScript. --- stdlib/source/lux/host/js.lux | 13 +++++++++---- .../lux/tool/compiler/phase/generation/js/runtime.lux | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'stdlib/source') 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 [ ] + [(def: #export ( value) + {#.doc "A 32-bit integer expression."} + (-> Computation) + (:abstraction (..argument (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) -- cgit v1.2.3