diff options
Diffstat (limited to 'new-luxc/source/luxc/compiler')
-rw-r--r-- | new-luxc/source/luxc/compiler/base.jvm.lux | 30 | ||||
-rw-r--r-- | new-luxc/source/luxc/compiler/expr.jvm.lux | 27 | ||||
-rw-r--r-- | new-luxc/source/luxc/compiler/runtime.jvm.lux | 6 | ||||
-rw-r--r-- | new-luxc/source/luxc/compiler/statement.jvm.lux | 26 |
4 files changed, 89 insertions, 0 deletions
diff --git a/new-luxc/source/luxc/compiler/base.jvm.lux b/new-luxc/source/luxc/compiler/base.jvm.lux new file mode 100644 index 000000000..f5784319a --- /dev/null +++ b/new-luxc/source/luxc/compiler/base.jvm.lux @@ -0,0 +1,30 @@ +(;module: + lux + (lux (control monad) + [io #- run] + (concurrency ["A" atom]) + (data ["E" error] + [text] + text/format) + host) + (luxc ["&" base])) + +(jvm-import java.lang.Class) +(jvm-import java.lang.ClassLoader) +(jvm-import org.objectweb.asm.MethodVisitor) + +(type: Blob Byte-Array) + +(type: JVM-State + {#visitor (Maybe MethodVisitor) + #loader ClassLoader + #store (A;Atom (D;Dict Text Blob)) + }) + +(def: host-state + JVM-State + (let [store (A;new (D;new text;Hash<Text>))] + {#visitor #;None + #loader (memory-class-loader store) + #store store + })) diff --git a/new-luxc/source/luxc/compiler/expr.jvm.lux b/new-luxc/source/luxc/compiler/expr.jvm.lux new file mode 100644 index 000000000..6655abd5f --- /dev/null +++ b/new-luxc/source/luxc/compiler/expr.jvm.lux @@ -0,0 +1,27 @@ +(;module: + lux + (lux (control monad) + (data text/format) + [macro #+ Monad<Lux>]) + (luxc ["&" base] + ["&;" module] + ["&;" env] + ["&;" analyser] + ["&;" synthesizer #+ Synthesis])) + +(type: #export JVM-Bytecode + Void) + +(type: Compiled + JVM-Bytecode) + +(def: (compile-synthesis synthesis) + (-> Synthesis Compiled) + (undefined)) + +(def: #export (compile input) + (-> AST (Lux Compiled)) + (|> input + &analyser;analyse + (Lux/map &synthesizer;synthesize) + (Lux/map compile-synthesis))) diff --git a/new-luxc/source/luxc/compiler/runtime.jvm.lux b/new-luxc/source/luxc/compiler/runtime.jvm.lux new file mode 100644 index 000000000..2d48b3617 --- /dev/null +++ b/new-luxc/source/luxc/compiler/runtime.jvm.lux @@ -0,0 +1,6 @@ +(;module: + lux + (lux (control monad) + (data text/format)) + (luxc ["&" base])) + diff --git a/new-luxc/source/luxc/compiler/statement.jvm.lux b/new-luxc/source/luxc/compiler/statement.jvm.lux new file mode 100644 index 000000000..c4c23746e --- /dev/null +++ b/new-luxc/source/luxc/compiler/statement.jvm.lux @@ -0,0 +1,26 @@ +(;module: + lux + (lux (control monad) + [io #- run] + (data ["E" error] + [text "T/" Eq<Text>] + text/format) + [macro #+ Monad<Lux>]) + (luxc ["&" base] + ["&;" module] + ["&;" env] + (compiler ["&;" expr]))) + +(def: (compile-def def-name def-value def-meta) + (-> Text AST AST (Lux Unit)) + (do Monad<Lux> + [=def-value (&expr;compile def-value) + =def-meta (&expr;compile def-meta)] + (undefined))) + +(def: (compile-program prog-args prog-body) + (-> Text AST (Lux Unit)) + (do Monad<Lux> + [=prog-body (&env;with-local [prog-args (type (List Text))] + (&expr;compile prog-body))] + (undefined))) |