aboutsummaryrefslogtreecommitdiff
path: root/lux-r/source/luxc/lang/translation/r/procedure/host.jvm.lux
diff options
context:
space:
mode:
authorEduardo Julian2020-05-30 15:19:28 -0400
committerEduardo Julian2020-05-30 15:19:28 -0400
commitb4d0eba7485caf0c6cf58de1193a9114fa273d8b (patch)
treef6f7fa2967bb5923347db1ed1d4c9b08e56bf8c6 /lux-r/source/luxc/lang/translation/r/procedure/host.jvm.lux
parent6eaa3b57f3f1ea2ce13b942bdb4ef502fc1729bc (diff)
Split new-luxc into lux-jvm and lux-r.
Diffstat (limited to 'lux-r/source/luxc/lang/translation/r/procedure/host.jvm.lux')
-rw-r--r--lux-r/source/luxc/lang/translation/r/procedure/host.jvm.lux89
1 files changed, 89 insertions, 0 deletions
diff --git a/lux-r/source/luxc/lang/translation/r/procedure/host.jvm.lux b/lux-r/source/luxc/lang/translation/r/procedure/host.jvm.lux
new file mode 100644
index 000000000..3bd33955f
--- /dev/null
+++ b/lux-r/source/luxc/lang/translation/r/procedure/host.jvm.lux
@@ -0,0 +1,89 @@
+(.module:
+ lux
+ (lux (control [monad #+ do])
+ (data [text]
+ text/format
+ (coll [list "list/" Functor<List>]
+ (dictionary ["dict" unordered #+ Dict])))
+ [macro "macro/" Monad<Meta>])
+ (luxc ["&" lang]
+ (lang ["la" analysis]
+ ["ls" synthesis]
+ (host [ruby #+ Ruby Expression Statement])))
+ [///]
+ (/// [".T" runtime])
+ (// ["@" common]))
+
+## (template [<name> <lua>]
+## [(def: (<name> _) @.Nullary <lua>)]
+
+## [lua//nil "nil"]
+## [lua//table "{}"]
+## )
+
+## (def: (lua//global proc translate inputs)
+## (-> Text @.Proc)
+## (case inputs
+## (^ (list [_ (#.Text name)]))
+## (do macro.Monad<Meta>
+## []
+## (wrap name))
+
+## _
+## (&.throw @.Wrong-Syntax (@.wrong-syntax proc inputs))))
+
+## (def: (lua//call proc translate inputs)
+## (-> Text @.Proc)
+## (case inputs
+## (^ (list& functionS argsS+))
+## (do {@ macro.Monad<Meta>}
+## [functionO (translate functionS)
+## argsO+ (monad.map @ translate argsS+)]
+## (wrap (lua.apply functionO argsO+)))
+
+## _
+## (&.throw @.Wrong-Syntax (@.wrong-syntax proc inputs))))
+
+## (def: lua-procs
+## @.Bundle
+## (|> (dict.new text.Hash<Text>)
+## (@.install "nil" (@.nullary lua//nil))
+## (@.install "table" (@.nullary lua//table))
+## (@.install "global" lua//global)
+## (@.install "call" lua//call)))
+
+## (def: (table//call proc translate inputs)
+## (-> Text @.Proc)
+## (case inputs
+## (^ (list& tableS [_ (#.Text field)] argsS+))
+## (do {@ macro.Monad<Meta>}
+## [tableO (translate tableS)
+## argsO+ (monad.map @ translate argsS+)]
+## (wrap (lua.method field tableO argsO+)))
+
+## _
+## (&.throw @.Wrong-Syntax (@.wrong-syntax proc inputs))))
+
+## (def: (table//get [fieldO tableO])
+## @.Binary
+## (runtimeT.lua//get tableO fieldO))
+
+## (def: (table//set [fieldO valueO tableO])
+## @.Trinary
+## (runtimeT.lua//set tableO fieldO valueO))
+
+## (def: table-procs
+## @.Bundle
+## (<| (@.prefix "table")
+## (|> (dict.new text.Hash<Text>)
+## (@.install "call" table//call)
+## (@.install "get" (@.binary table//get))
+## (@.install "set" (@.trinary table//set)))))
+
+(def: #export procedures
+ @.Bundle
+ (<| (@.prefix "lua")
+ (dict.new text.Hash<Text>)
+ ## (|> lua-procs
+ ## (dict.merge table-procs))
+ ))