diff options
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/js/eval.jvm.lux')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/js/eval.jvm.lux | 29 |
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)) |