diff options
author | Eduardo Julian | 2017-05-09 17:48:27 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-05-09 17:48:27 -0400 |
commit | dd5220e13b03c8f85972feac535a34ef64525222 (patch) | |
tree | 2ac08a118eaa63f11c2397a08eaca74d199f2d1e /new-luxc/source/luxc/compiler/expr.jvm.lux | |
parent | 7b74c1258f345d576b0c798303b0ed28f1734368 (diff) |
- Added tests for some kinds of analysis.
- WIP: Porting more code.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/compiler/expr.jvm.lux | 57 |
1 files changed, 42 insertions, 15 deletions
diff --git a/new-luxc/source/luxc/compiler/expr.jvm.lux b/new-luxc/source/luxc/compiler/expr.jvm.lux index f0508c0d2..33a41541b 100644 --- a/new-luxc/source/luxc/compiler/expr.jvm.lux +++ b/new-luxc/source/luxc/compiler/expr.jvm.lux @@ -2,29 +2,56 @@ lux (lux (control monad) (data text/format) - [macro #+ Monad<Lux> "Lux/" Monad<Lux>]) + [macro #+ Monad<Lux> "Lux/" Monad<Lux>] + [host #+ jvm-import]) (luxc ["&" base] - lang + (lang ["ls" synthesis]) ["&;" analyser] - ["&;" synthesizer])) + ["&;" synthesizer] + (compiler ["&;" common]))) -(type: #export JVM-Bytecode - Void) +(jvm-import #long java.lang.Object) -(type: #export Compiled - JVM-Bytecode) +(jvm-import org.objectweb.asm.Opcodes) + +(jvm-import org.objectweb.asm.MethodVisitor + (visitLdcInsn [Object] void)) + +(def: unit-value Text "\u0000unit\u0000") + +(def: (compiler-literal value) + (-> Top (Lux &common;Compiled)) + (do Monad<Lux> + [visitor &common;get-visitor + #let [_ (MethodVisitor.visitLdcInsn [(:! java.lang.Object value)])]] + (wrap []))) (def: (compile-synthesis synthesis) - (-> Synthesis Compiled) - (undefined)) + (-> ls;Synthesis (Lux &common;Compiled)) + (case synthesis + #ls;Unit + (compiler-literal &common;unit-value) + + (^template [<tag>] + (<tag> value) + (compiler-literal value)) + ([#ls;Bool] + [#ls;Nat] + [#ls;Int] + [#ls;Deg] + [#ls;Real] + [#ls;Char] + [#ls;Text]) + + _ + (macro;fail "Unrecognized synthesis."))) (def: (eval type code) - Eval + &;Eval (undefined)) (def: #export (compile input) - (-> Code (Lux Compiled)) - (|> input - (&analyser;analyse eval) - (Lux/map &synthesizer;synthesize) - (Lux/map compile-synthesis))) + (-> Code (Lux &common;Compiled)) + (do Monad<Lux> + [analysis (&analyser;analyse eval input)] + (compile-synthesis (&synthesizer;synthesize analysis)))) |