From 9cd2927a4f6175784e081d6b512d3e900c8069e7 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 12 Jun 2017 21:14:55 -0400 Subject: - Renamed the "compilation" phase as the "generation" phase. - Implemented compilation of primitives. - Implemented compilation of structures. --- new-luxc/source/luxc/compiler/base.jvm.lux | 29 ----------- new-luxc/source/luxc/compiler/common.jvm.lux | 65 ------------------------- new-luxc/source/luxc/compiler/expr.jvm.lux | 62 ----------------------- new-luxc/source/luxc/compiler/runtime.jvm.lux | 11 ----- new-luxc/source/luxc/compiler/statement.jvm.lux | 25 ---------- 5 files changed, 192 deletions(-) delete mode 100644 new-luxc/source/luxc/compiler/base.jvm.lux delete mode 100644 new-luxc/source/luxc/compiler/common.jvm.lux delete mode 100644 new-luxc/source/luxc/compiler/expr.jvm.lux delete mode 100644 new-luxc/source/luxc/compiler/runtime.jvm.lux delete mode 100644 new-luxc/source/luxc/compiler/statement.jvm.lux (limited to 'new-luxc/source/luxc/compiler') diff --git a/new-luxc/source/luxc/compiler/base.jvm.lux b/new-luxc/source/luxc/compiler/base.jvm.lux deleted file mode 100644 index 01a97aec4..000000000 --- a/new-luxc/source/luxc/compiler/base.jvm.lux +++ /dev/null @@ -1,29 +0,0 @@ -(;module: - lux - (lux (control monad) - [io #- run] - (concurrency ["A" atom]) - (data [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))] - {#visitor #;None - #loader (memory-class-loader store) - #store store - })) diff --git a/new-luxc/source/luxc/compiler/common.jvm.lux b/new-luxc/source/luxc/compiler/common.jvm.lux deleted file mode 100644 index bd5487ef6..000000000 --- a/new-luxc/source/luxc/compiler/common.jvm.lux +++ /dev/null @@ -1,65 +0,0 @@ -(;module: - lux - (lux (concurrency ["A" atom]) - (data ["R" result] - (coll ["D" dict])) - [macro] - [host #+ jvm-import])) - -## [Host] -(jvm-import org.objectweb.asm.MethodVisitor - (visitLdcInsn [Object] void)) - -(jvm-import java.lang.ClassLoader) - -## [Types] -(type: #export Compiled - Unit) - -(type: #export Blob host;Byte-Array) - -(type: #export Class-Store (A;Atom (D;Dict Text Blob))) - -(type: #export Host - {#visitor (Maybe MethodVisitor) - #loader ClassLoader - #store Class-Store}) - -(def: #export unit-value Text "\u0000unit\u0000") - -(def: (visitor::get compiler) - (-> Compiler (Maybe MethodVisitor)) - (|> (get@ #;host compiler) - (:! Host) - (get@ #visitor))) - -(def: (visitor::put ?visitor compiler) - (-> (Maybe MethodVisitor) Compiler Compiler) - (update@ #;host - (function [host] - (|> host - (:! Host) - (set@ #visitor ?visitor) - (:! Void))) - compiler)) - -(def: #export get-visitor - (Lux MethodVisitor) - (function [compiler] - (case (visitor::get compiler) - #;None - (#R;Error "No visitor has been set.") - - (#;Some visitor) - (#R;Success [compiler visitor])))) - -(def: #export (with-visitor visitor body) - (All [a] (-> MethodVisitor (Lux a) (Lux a))) - (function [compiler] - (case (macro;run' (visitor::put (#;Some visitor) compiler) body) - (#R;Error error) - (#R;Error error) - - (#R;Success [compiler' output]) - (#R;Success [(visitor::put (visitor::get compiler) compiler') - output])))) diff --git a/new-luxc/source/luxc/compiler/expr.jvm.lux b/new-luxc/source/luxc/compiler/expr.jvm.lux deleted file mode 100644 index b2e4923c4..000000000 --- a/new-luxc/source/luxc/compiler/expr.jvm.lux +++ /dev/null @@ -1,62 +0,0 @@ -(;module: - lux - (lux (control monad) - (data text/format) - [macro #+ Monad "Lux/" Monad] - [host #+ jvm-import]) - (luxc ["&" base] - (lang ["la" analysis] - ["ls" synthesis]) - ["&;" analyser] - ["&;" synthesizer] - (compiler ["&;" common]))) - -(jvm-import #long java.lang.Object) - -(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 - [visitor &common;get-visitor - #let [_ (MethodVisitor.visitLdcInsn [(:! java.lang.Object value)])]] - (wrap []))) - -(def: (compile-synthesis synthesis) - (-> ls;Synthesis (Lux &common;Compiled)) - (case synthesis - #ls;Unit - (compiler-literal &common;unit-value) - - (^template [] - ( 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 - (undefined)) - -(def: analyse - &;Analyser - (&analyser;analyser eval)) - -(def: #export (compile input) - (-> Code (Lux &common;Compiled)) - (do Monad - [analysis (analyse input)] - (compile-synthesis (&synthesizer;synthesize analysis)))) diff --git a/new-luxc/source/luxc/compiler/runtime.jvm.lux b/new-luxc/source/luxc/compiler/runtime.jvm.lux deleted file mode 100644 index 16e072194..000000000 --- a/new-luxc/source/luxc/compiler/runtime.jvm.lux +++ /dev/null @@ -1,11 +0,0 @@ -(;module: - lux - (lux (control monad) - (concurrency ["P" promise "P/" Monad]) - (data text/format - ["R" result])) - (luxc ["&" base])) - -(def: #export (compile-runtime compiler) - (-> Compiler (P;Promise (R;Result Compiler))) - (P/wrap (#R;Success compiler))) diff --git a/new-luxc/source/luxc/compiler/statement.jvm.lux b/new-luxc/source/luxc/compiler/statement.jvm.lux deleted file mode 100644 index 96263181f..000000000 --- a/new-luxc/source/luxc/compiler/statement.jvm.lux +++ /dev/null @@ -1,25 +0,0 @@ -(;module: - lux - (lux (control monad) - [io #- run] - (data [text "T/" Eq] - text/format) - [macro #+ Monad]) - (luxc ["&" base] - ["&;" module] - ["&;" env] - (compiler ["&;" expr]))) - -(def: #export (compile-def def-name def-value def-meta) - (-> Text Code Code (Lux Unit)) - (do Monad - [=def-value (&expr;compile def-value) - =def-meta (&expr;compile def-meta)] - (undefined))) - -(def: #export (compile-program prog-args prog-body) - (-> Text Code (Lux Unit)) - (do Monad - [=prog-body (&env;with-local [prog-args (type (List Text))] - (&expr;compile prog-body))] - (undefined))) -- cgit v1.2.3