From b4d0eba7485caf0c6cf58de1193a9114fa273d8b Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 30 May 2020 15:19:28 -0400 Subject: Split new-luxc into lux-jvm and lux-r. --- .../source/luxc/lang/translation/jvm/reference.lux | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 lux-jvm/source/luxc/lang/translation/jvm/reference.lux (limited to 'lux-jvm/source/luxc/lang/translation/jvm/reference.lux') 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 [ ] + [(def: #export + (-> Nat Text) + (|>> %.nat (format )))] + + [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)))) -- cgit v1.2.3