aboutsummaryrefslogtreecommitdiff
path: root/lux-jvm/source/luxc/lang/translation/jvm/reference.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-jvm/source/luxc/lang/translation/jvm/reference.lux
parent6eaa3b57f3f1ea2ce13b942bdb4ef502fc1729bc (diff)
Split new-luxc into lux-jvm and lux-r.
Diffstat (limited to 'lux-jvm/source/luxc/lang/translation/jvm/reference.lux')
-rw-r--r--lux-jvm/source/luxc/lang/translation/jvm/reference.lux65
1 files changed, 65 insertions, 0 deletions
diff --git a/lux-jvm/source/luxc/lang/translation/jvm/reference.lux b/lux-jvm/source/luxc/lang/translation/jvm/reference.lux
new file mode 100644
index 000000000..6bcf4a2e5
--- /dev/null
+++ b/lux-jvm/source/luxc/lang/translation/jvm/reference.lux
@@ -0,0 +1,65 @@
+(.module:
+ [lux #*
+ [abstract
+ [monad (#+ do)]]
+ [data
+ [text
+ ["%" format (#+ format)]]]
+ [target
+ [jvm
+ ["." type]]]
+ [tool
+ [compiler
+ ["." reference (#+ Register Variable)]
+ ["." phase ("operation@." monad)]
+ [meta
+ [archive (#+ Archive)]]
+ [language
+ [lux
+ ["." generation]]]]]]
+ [luxc
+ [lang
+ [host
+ [jvm (#+ Inst Operation)
+ ["_" inst]]]]]
+ ["." //
+ ["#." runtime]])
+
+(template [<name> <prefix>]
+ [(def: #export <name>
+ (-> Nat Text)
+ (|>> %.nat (format <prefix>)))]
+
+ [foreign-name "f"]
+ [partial-name "p"]
+ )
+
+(def: (foreign archive variable)
+ (-> Archive Register (Operation Inst))
+ (do {@ phase.monad}
+ [class-name (:: @ map //.class-name
+ (generation.context archive))]
+ (wrap (|>> (_.ALOAD 0)
+ (_.GETFIELD (type.class class-name (list))
+ (|> variable .nat foreign-name)
+ //.$Value)))))
+
+(def: local
+ (-> Register Inst)
+ (|>> _.ALOAD))
+
+(def: #export (variable archive variable)
+ (-> Archive Variable (Operation Inst))
+ (case variable
+ (#reference.Local variable)
+ (operation@wrap (local variable))
+
+ (#reference.Foreign variable)
+ (foreign archive variable)))
+
+(def: #export (constant archive name)
+ (-> Archive Name (Operation Inst))
+ (do {@ phase.monad}
+ [class-name (:: @ map //.class-name
+ (generation.remember archive name))]
+ (wrap (_.GETSTATIC (type.class class-name (list)) //.value-field //.$Value))))