diff options
author | Eduardo Julian | 2018-05-06 23:27:12 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-05-06 23:27:12 -0400 |
commit | fb72b937aba7886ce204379e97aa06c327a4029f (patch) | |
tree | 20bc243f1605c5b6c37b833b8046b82eac805494 /new-luxc/source/luxc/lang/translation/lua | |
parent | 0b53bcc87ad3563daedaa64306d0bbe6df01ca49 (diff) |
- Implemented Nat functionality in pure Lux.
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/lua')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux | 45 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux | 31 |
2 files changed, 4 insertions, 72 deletions
diff --git a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux index bdba05a9d..a9849b557 100644 --- a/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/procedure/common.jvm.lux @@ -197,9 +197,6 @@ Nullary (<encode> <const>))] - [nat//min 0 lua.int] - [nat//max -1 lua.int] - [frac//smallest Double::MIN_VALUE lua.float] [frac//min (f/* -1.0 Double::MAX_VALUE) lua.float] [frac//max Double::MAX_VALUE lua.float] @@ -238,12 +235,6 @@ [int//div lua.//] [int//rem lua.%] - [nat//add lua.+] - [nat//sub lua.-] - [nat//mul lua.*] - [nat//div runtimeT.nat///] - [nat//rem runtimeT.nat//%] - [deg//add lua.+] [deg//sub lua.-] [deg//mul runtimeT.deg//*] @@ -275,21 +266,10 @@ Binary (<cmp> paramO subjectO))] - [nat//= lua.=] - [nat//< runtimeT.nat//<] [int//= lua.=] [int//< lua.<] [deg//= lua.=] - [deg//< runtimeT.nat//<] - ) - -(do-template [<name>] - [(def: (<name> inputO) - Unary - inputO)] - - [nat//to-int] - [int//to-nat] + [deg//< lua.<] ) (def: frac//encode @@ -320,7 +300,7 @@ [text//hash runtimeT.text//hash] ) -(def: nat//char +(def: int//char Unary (|>> (list) (lua.apply "string.char"))) @@ -466,22 +446,6 @@ (install "arithmetic-right-shift" (binary bit//arithmetic-right-shift)) ))) -(def: nat-procs - Bundle - (<| (prefix "nat") - (|> (dict.new text.Hash<Text>) - (install "+" (binary nat//add)) - (install "-" (binary nat//sub)) - (install "*" (binary nat//mul)) - (install "/" (binary nat//div)) - (install "%" (binary nat//rem)) - (install "=" (binary nat//=)) - (install "<" (binary nat//<)) - (install "min" (nullary nat//min)) - (install "max" (nullary nat//max)) - (install "to-int" (unary nat//to-int)) - (install "char" (unary nat//char))))) - (def: int-procs Bundle (<| (prefix "int") @@ -495,8 +459,8 @@ (install "<" (binary int//<)) (install "min" (nullary int//min)) (install "max" (nullary int//max)) - (install "to-nat" (unary int//to-nat)) - (install "to-frac" (unary int//to-frac))))) + (install "to-frac" (unary int//to-frac)) + (install "char" (unary int//char))))) (def: deg-procs Bundle @@ -620,7 +584,6 @@ (<| (prefix "lux") (|> lux-procs (dict.merge bit-procs) - (dict.merge nat-procs) (dict.merge int-procs) (dict.merge deg-procs) (dict.merge frac-procs) diff --git a/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux b/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux index 64253b1c3..cd5d0c090 100644 --- a/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux +++ b/new-luxc/source/luxc/lang/translation/lua/runtime.jvm.lux @@ -197,36 +197,6 @@ (format @@bit//count @@bit//logical-right-shift)) -(runtime: (nat//< param subject) - (lua.return! (lua.apply "math.ult" (list subject param)))) - -(runtime: (nat/// param subject) - (lua.if! (lua.< (lua.int 0) param) - (lua.if! (nat//< param subject) - (lua.return! (lua.int 0)) - (lua.return! (lua.int 1))) - (lua.block! (list (lua.local! "quotient" (#.Some (|> subject - (lua.bit-shr (lua.int 1)) - (lua.// param) - (lua.bit-shl (lua.int 1))))) - (lua.local! "remainder" (#.Some (lua.- (lua.* param "quotient") - subject))) - (lua.if! (lua.not (nat//< param "remainder")) - (lua.return! (lua.+ (lua.int 1) "quotient")) - (lua.return! "quotient")))))) - -(runtime: (nat//% param subject) - (let [flat (|> subject - (nat/// param) - (lua.* param))] - (lua.return! (lua.- flat subject)))) - -(def: runtime//nat - Runtime - (format @@nat//< - @@nat/// - @@nat//%)) - (runtime: deg//low-mask (|> (lua.int 1) (lua.bit-shl (lua.int 32)) @@ -477,7 +447,6 @@ (format runtime//lux runtime//adt runtime//bit - runtime//nat runtime//deg runtime//text runtime//array |