diff options
Diffstat (limited to 'new-luxc/source/luxc/lang/translation/primitive.jvm.lux')
-rw-r--r-- | new-luxc/source/luxc/lang/translation/primitive.jvm.lux | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/new-luxc/source/luxc/lang/translation/primitive.jvm.lux b/new-luxc/source/luxc/lang/translation/primitive.jvm.lux new file mode 100644 index 000000000..72b5f4e9d --- /dev/null +++ b/new-luxc/source/luxc/lang/translation/primitive.jvm.lux @@ -0,0 +1,36 @@ +(;module: + lux + (lux (control monad) + (data text/format) + [meta "meta/" Monad<Meta>]) + (luxc ["&" base] + [";L" host] + (host ["$" jvm] + (jvm ["$i" inst] + ["$t" type])) + (lang ["la" analysis] + ["ls" synthesis] + (translation [";T" common]))) + [../runtime]) + +(def: #export generate-unit + (Meta $;Inst) + (meta/wrap ($i;string hostL;unit))) + +(def: #export (generate-bool value) + (-> Bool (Meta $;Inst)) + (meta/wrap ($i;GETSTATIC "java.lang.Boolean" + (if value "TRUE" "FALSE") + ($t;class "java.lang.Boolean" (list))))) + +(do-template [<name> <type> <load> <wrap>] + [(def: #export (<name> value) + (-> <type> (Meta $;Inst)) + (meta/wrap (|>. (<load> value) <wrap>)))] + + [generate-nat Nat (|>. (:! Int) $i;long) ($i;wrap #$;Long)] + [generate-int Int $i;long ($i;wrap #$;Long)] + [generate-deg Deg (|>. (:! Int) $i;long) ($i;wrap #$;Long)] + [generate-frac Frac $i;double ($i;wrap #$;Double)] + [generate-text Text $i;string id] + ) |