aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/jvm/reference.lux
diff options
context:
space:
mode:
authorEduardo Julian2019-04-16 20:53:41 -0400
committerEduardo Julian2019-04-16 20:53:41 -0400
commit697707d8560a5735be38fd9b1ff91a02c289d48f (patch)
tree7f9e81974c9ec3ede82e7f2392ebba037e3e9df8 /new-luxc/source/luxc/lang/translation/jvm/reference.lux
parent42248854f0cb5e3364e6aae25527cee65cbda3e8 (diff)
Made some new-luxc modules "old".
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/jvm/reference.lux')
-rw-r--r--new-luxc/source/luxc/lang/translation/jvm/reference.lux57
1 files changed, 57 insertions, 0 deletions
diff --git a/new-luxc/source/luxc/lang/translation/jvm/reference.lux b/new-luxc/source/luxc/lang/translation/jvm/reference.lux
new file mode 100644
index 000000000..c821a9de2
--- /dev/null
+++ b/new-luxc/source/luxc/lang/translation/jvm/reference.lux
@@ -0,0 +1,57 @@
+(.module:
+ [lux #*
+ [abstract
+ [monad (#+ do)]]
+ [data
+ [text
+ format]]
+ [tool
+ [compiler
+ ["." name]
+ ["." reference (#+ Register Variable)]
+ ["." phase ("operation/." monad)
+ ["." generation]]]]]
+ [luxc
+ [lang
+ [host
+ [jvm (#+ Inst Operation)
+ ["$t" type]
+ ["_" inst]]]]]
+ ["." //])
+
+(template [<name> <prefix>]
+ [(def: #export (<name> idx)
+ (-> Nat Text)
+ (|> idx %n (format <prefix>)))]
+
+ [foreign-name "f"]
+ [partial-name "p"]
+ )
+
+(def: (foreign variable)
+ (-> Register (Operation Inst))
+ (do phase.monad
+ [function-class generation.context]
+ (wrap (|>> (_.ALOAD 0)
+ (_.GETFIELD function-class
+ (|> variable .nat foreign-name)
+ //.$Object)))))
+
+(def: local
+ (-> Register (Operation Inst))
+ (|>> _.ALOAD operation/wrap))
+
+(def: #export (variable variable)
+ (-> Variable (Operation Inst))
+ (case variable
+ (#reference.Local variable)
+ (local variable)
+
+ (#reference.Foreign variable)
+ (foreign variable)))
+
+(def: #export (constant name)
+ (-> Name (Operation Inst))
+ (do phase.monad
+ [bytecode-name (generation.remember name)]
+ (operation/wrap (_.GETSTATIC bytecode-name //.value-field //.$Object))))