diff options
author | Eduardo Julian | 2018-06-15 00:11:33 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-06-15 00:11:33 -0400 |
commit | bcd3d9ee8f6797f758a2abea98d5cb6a74cc7df0 (patch) | |
tree | b122b9ecf2d5333ba97cffbadfeee00eba2e1cf8 /new-luxc/source/luxc/lang/translation/js | |
parent | 0190e084c6f44be32ea2bc5a89ef55b52bdc789b (diff) |
- WIP: Adjustments to new-luxc based on recent changes to stdlib.
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/js')
8 files changed, 27 insertions, 27 deletions
diff --git a/new-luxc/source/luxc/lang/translation/js/case.jvm.lux b/new-luxc/source/luxc/lang/translation/js/case.jvm.lux index 82a8bb5c9..3abd8c55c 100644 --- a/new-luxc/source/luxc/lang/translation/js/case.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/case.jvm.lux @@ -31,7 +31,7 @@ [valueJS (translate valueS)] (wrap (list/fold (function (_ [idx tail?] source) (let [method (if tail? runtimeT.product//right runtimeT.product//left)] - (format method "(" source "," (|> idx nat-to-int %i) ")"))) + (format method "(" source "," (|> idx .int %i) ")"))) (format "(" valueJS ")") path)))) @@ -111,13 +111,13 @@ (^template [<pm> <getter>] (^code (<pm> (~ [_ (#.Nat idx)]))) - (meta/wrap (push-cursor (format <getter> "(" peek-cursor "," (|> idx nat-to-int %i) ")")))) + (meta/wrap (push-cursor (format <getter> "(" peek-cursor "," (|> idx .int %i) ")")))) (["lux case tuple left" runtimeT.product//left] ["lux case tuple right" runtimeT.product//right]) (^template [<pm> <flag>] (^code (<pm> (~ [_ (#.Nat idx)]))) - (meta/wrap (format "temp = " runtimeT.sum//get "(" peek-cursor "," (|> idx nat-to-int %i) "," <flag> ");" + (meta/wrap (format "temp = " runtimeT.sum//get "(" peek-cursor "," (|> idx .int %i) "," <flag> ");" "if(temp == null) {" fail-pattern-matching "}" 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 04121b944..94136f356 100644 --- a/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/eval.jvm.lux @@ -64,10 +64,10 @@ [[(Number::longValue [] (:! Number high)) (Number::longValue [] (:! Number low))] [high low]]) - (#.Some (nat-to-int (n/+ (|> high (:! Nat) (bit.left-shift +32)) - (if (i/< 0 (:! Int low)) - (|> low (:! Nat) (bit.left-shift +32) (bit.logical-right-shift +32)) - (|> low (:! Nat)))))) + (#.Some (.int (n/+ (|> high (:! Nat) (bit.left-shift +32)) + (if (i/< 0 (:! Int low)) + (|> low (:! Nat) (bit.left-shift +32) (bit.logical-right-shift +32)) + (|> low (:! Nat)))))) _ #.None)) @@ -90,24 +90,24 @@ (def: (array lux-object js-object) (-> (-> Object (Error Any)) ScriptObjectMirror (Maybe (Array Object))) (if (JSObject::isArray [] js-object) - (let [init-num-keys (int-to-nat (ScriptObjectMirror::size [] js-object))] + (let [init-num-keys (.nat (ScriptObjectMirror::size [] js-object))] (loop [num-keys init-num-keys idx +0 output (: (Array Object) (array.new init-num-keys))] (if (n/< num-keys idx) - (let [idx-key (|> idx nat-to-int %i)] + (let [idx-key (|> idx .int %i)] (case (JSObject::getMember idx-key js-object) (#.Some member) (case (lux-object member) (#e.Success parsed-member) - (recur num-keys (n/inc idx) (array.write idx (:! Object parsed-member) output)) + (recur num-keys (inc idx) (array.write idx (:! Object parsed-member) output)) (#e.Error error) #.None) #.None - (recur num-keys (n/inc idx) output))) + (recur num-keys (inc idx) output))) (#.Some output)))) #.None)) diff --git a/new-luxc/source/luxc/lang/translation/js/function.jvm.lux b/new-luxc/source/luxc/lang/translation/js/function.jvm.lux index b3c6761cd..ef5ea668e 100644 --- a/new-luxc/source/luxc/lang/translation/js/function.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/function.jvm.lux @@ -21,7 +21,7 @@ (wrap (format functionJS "(" (text.join-with "," argsJS+) ")")))) (def: (input-declaration register) - (format "var " (referenceT.variable (n/inc register)) " = arguments[" (|> register nat-to-int %i) "];")) + (format "var " (referenceT.variable (inc register)) " = arguments[" (|> register .int %i) "];")) (def: (with-closure inits function) (-> (List Expression) Expression Expression) @@ -30,7 +30,7 @@ (list) _ - (|> (list.n/range +0 (n/dec (list.size inits))) + (|> (list.n/range +0 (dec (list.size inits))) (list/map referenceT.closure)))] (format "(function(" (text.join-with "," closure) ") {" "return " function @@ -47,11 +47,11 @@ (//.with-anchor [function-name +1] (translate bodyS)))) closureJS+ (monad.map @ referenceT.translate-variable env) - #let [args-initsJS+ (|> (list.n/range +0 (n/dec arity)) + #let [args-initsJS+ (|> (list.n/range +0 (dec arity)) (list/map input-declaration) (text.join-with "")) selfJS (format "var " (referenceT.variable +0) " = " function-name ";") - arityJS (|> arity nat-to-int %i)]] + arityJS (|> arity .int %i)]] (wrap (<| (with-closure closureJS+) (format "(function " function-name "() {" "\"use strict\";" diff --git a/new-luxc/source/luxc/lang/translation/js/loop.jvm.lux b/new-luxc/source/luxc/lang/translation/js/loop.jvm.lux index 657982556..c63cb2d32 100644 --- a/new-luxc/source/luxc/lang/translation/js/loop.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/loop.jvm.lux @@ -20,7 +20,7 @@ initsJS+ (monad.map @ translate initsS+) bodyJS (//.with-anchor [loop-name offset] (translate bodyS)) - #let [registersJS+ (|> (list.n/range +0 (n/dec (list.size initsS+))) + #let [registersJS+ (|> (list.n/range +0 (dec (list.size initsS+))) (list/map (|>> (n/+ offset) referenceT.variable)))]] (wrap (format "(function " loop-name "(" (text.join-with "," registersJS+) ") {" "return " bodyJS ";" diff --git a/new-luxc/source/luxc/lang/translation/js/primitive.jvm.lux b/new-luxc/source/luxc/lang/translation/js/primitive.jvm.lux index 270fa510d..305f46adf 100644 --- a/new-luxc/source/luxc/lang/translation/js/primitive.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/primitive.jvm.lux @@ -13,21 +13,21 @@ (-> Bool (Meta Expression)) (|>> %b meta/wrap)) -(def: low-mask Nat (n/dec (bit.left-shift +32 +1))) +(def: low-mask Nat (dec (bit.left-shift +32 +1))) (def: #export (translate-nat value) (-> Nat (Meta Expression)) (let [high (|> value (bit.logical-right-shift +32) - nat-to-int %i) + .int %i) low (|> value (bit.and low-mask) - nat-to-int %i)] + .int %i)] (meta/wrap (format runtimeT.int//new "(" high "," low ")")))) (def: #export translate-int (-> Int (Meta Expression)) - (|>> int-to-nat translate-nat)) + (|>> .nat translate-nat)) (def: deg-to-nat (-> Deg Nat) diff --git a/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux index 54a557ec9..fede43875 100644 --- a/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/procedure/common.jvm.lux @@ -57,8 +57,8 @@ (def: (wrong-arity proc expected actual) (-> Text Nat Nat Text) (format "Wrong number of arguments for " (%t proc) "\n" - "Expected: " (|> expected nat-to-int %i) "\n" - " Actual: " (|> actual nat-to-int %i))) + "Expected: " (|> expected .int %i) "\n" + " Actual: " (|> actual .int %i))) (syntax: (arity: {name s.local-symbol} {arity s.nat}) (with-gensyms [g!_ g!proc g!name g!translate g!inputs] diff --git a/new-luxc/source/luxc/lang/translation/js/reference.jvm.lux b/new-luxc/source/luxc/lang/translation/js/reference.jvm.lux index 0c5cc3a44..e4231ba6b 100644 --- a/new-luxc/source/luxc/lang/translation/js/reference.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/reference.jvm.lux @@ -12,7 +12,7 @@ (do-template [<register> <translation> <prefix>] [(def: #export (<register> register) (-> Register Expression) - (format <prefix> (%i (nat-to-int register)))) + (format <prefix> (%i (.int register)))) (def: #export (<translation> register) (-> Register (Meta Expression)) @@ -25,7 +25,7 @@ (-> Variable (Meta Expression)) (if (variableL.captured? var) (translate-captured (variableL.captured-register var)) - (translate-local (int-to-nat var)))) + (translate-local (.nat var)))) (def: #export global (-> Ident Expression) diff --git a/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux index 2c7303c31..6039a33c7 100644 --- a/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/js/runtime.jvm.lux @@ -27,7 +27,7 @@ (def: #export (variant tag last? value) (-> Nat Bool Expression Expression) - (variant' (%i (nat-to-int tag)) (flag last?) value)) + (variant' (%i (.int tag)) (flag last?) value)) (def: none Expression @@ -69,9 +69,9 @@ (def: #export (int value) (-> Int Expression) (format "({" - //.int-high-field " : " (|> value int-to-nat //.high nat-to-int %i) + //.int-high-field " : " (|> value .nat //.high .int %i) ", " - //.int-low-field " : " (|> value int-to-nat //.low nat-to-int %i) + //.int-low-field " : " (|> value .nat //.low .int %i) "})")) (def: #export frac |