aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux
diff options
context:
space:
mode:
authorEduardo Julian2018-02-17 11:40:12 -0400
committerEduardo Julian2018-02-17 11:40:12 -0400
commitd01f75d220539efd7d58ee9534d3ef3a7bbc3cdc (patch)
treeb0b4f7d06b3e57b3ec304a1323feaa1c44f605c9 /new-luxc/source/luxc/lang/translation/js/eval.jvm.lux
parent24b5c3a973dbfea7bd3de102c909af5483ade0f7 (diff)
- Added tests for normal JS (non-procedure) behavior.
- Fixed a few bugs.
Diffstat (limited to '')
-rw-r--r--new-luxc/source/luxc/lang/translation/js/eval.jvm.lux29
1 files changed, 11 insertions, 18 deletions
diff --git a/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux b/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux
index bcf70bcae..fada5a70c 100644
--- a/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux
+++ b/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux
@@ -12,13 +12,14 @@
(host.import java/lang/Object
(toString [] String))
-(host.import java/lang/Number
- (doubleValue [] double)
- (longValue [] Long))
-
(host.import java/lang/Integer
(longValue [] Long))
+(host.import java/lang/Number
+ (doubleValue [] double)
+ (longValue [] Long)
+ (intValue [] Integer))
+
(host.import javax/script/ScriptEngine
(eval [String] #try #? Object))
@@ -51,18 +52,14 @@
[[(Number::longValue [] (:! Number high))
(Number::longValue [] (:! Number low))]
[high low]])
- (#.Some (nat-to-int (n/+ (|> high (:! Int) int-to-nat (bit.shift-left +32))
- (|> low (:! Int) int-to-nat))))
+ (#.Some (nat-to-int (n/+ (|> high (:! Nat) (bit.shift-left +32))
+ (if (i/< 0 (:! Int low))
+ (|> low (:! Nat) (bit.shift-left +32) (bit.shift-right +32))
+ (|> low (:! Nat))))))
_
#.None))
-(def: (extend-array by input)
- (All [a] (-> Nat (Array a) (Array a)))
- (let [size (array.size input)]
- (|> (array.new (n/+ by size))
- (array.copy size +0 input +0))))
-
(def: (array element-parser js-object)
(-> (-> Object (Error Top)) ScriptObjectMirror (Maybe (Array Object)))
(if (JSObject::isArray [] js-object)
@@ -77,17 +74,13 @@
(#.Some member)
(case (element-parser member)
(#e.Success parsed-member)
- (recur num-keys
- (n/inc idx)
- (array.write idx (:! Object parsed-member) output))
+ (recur num-keys (n/inc idx) (array.write idx (:! Object parsed-member) output))
(#e.Error error)
#.None)
#.None
- (recur (n/inc num-keys)
- (n/inc idx)
- (extend-array +1 output))))
+ (recur num-keys (n/inc idx) output)))
(#.Some output))))
#.None))