aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/generator/reference.jvm.lux
diff options
context:
space:
mode:
Diffstat (limited to 'new-luxc/source/luxc/generator/reference.jvm.lux')
-rw-r--r--new-luxc/source/luxc/generator/reference.jvm.lux26
1 files changed, 26 insertions, 0 deletions
diff --git a/new-luxc/source/luxc/generator/reference.jvm.lux b/new-luxc/source/luxc/generator/reference.jvm.lux
new file mode 100644
index 000000000..28c936036
--- /dev/null
+++ b/new-luxc/source/luxc/generator/reference.jvm.lux
@@ -0,0 +1,26 @@
+(;module:
+ lux
+ (lux (control [monad #+ do])
+ (data text/format)
+ [macro "lux/" Monad<Lux>])
+ (luxc (lang ["ls" synthesis])
+ (generator [";G" common]
+ [";G" function]
+ (host ["$" jvm]
+ (jvm ["$t" type]
+ ["$i" inst])))))
+
+(def: $Object $;Type ($t;class "java.lang.Object" (list)))
+
+(def: #export (generate-captured variable)
+ (-> ls;Variable (Lux $;Inst))
+ (do macro;Monad<Lux>
+ [function-class commonG;function]
+ (wrap (|>. ($i;ALOAD +0)
+ ($i;GETFIELD function-class
+ (|> variable i.inc (i.* -1) int-to-nat functionG;captured)
+ $Object)))))
+
+(def: #export (generate-variable variable)
+ (-> ls;Variable (Lux $;Inst))
+ (lux/wrap ($i;ALOAD (int-to-nat variable))))