From 3744a2212a89d4ab0f176350d2d2f90696235a40 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 19 Sep 2017 19:24:09 -0400 Subject: - Function generation. --- new-luxc/source/luxc/generator/reference.jvm.lux | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 new-luxc/source/luxc/generator/reference.jvm.lux (limited to 'new-luxc/source/luxc/generator/reference.jvm.lux') 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]) + (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 + [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)))) -- cgit v1.2.3