diff options
author | Eduardo Julian | 2017-11-01 00:51:45 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-11-01 00:51:45 -0400 |
commit | 012f6bd41e527479dddbccbdab10daa78fd9a0fd (patch) | |
tree | 621f344a09acd52736f343d94582b3f1a2f0c5f9 /new-luxc/source/luxc/lang/translation/primitive.jvm.lux | |
parent | 71d7a4c7206155e09f3e1e1d8699561ea6967382 (diff) |
- Re-organized code-generation, and re-named it "translation".
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] + ) |