From 296d087530cb142efec1dea159770346bb43c3c0 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 15 Nov 2017 19:51:33 -0400 Subject: - Heavy refactoring. --- new-luxc/source/luxc/lang/translation.lux | 42 ++++++++++++++----------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'new-luxc/source/luxc/lang/translation.lux') diff --git a/new-luxc/source/luxc/lang/translation.lux b/new-luxc/source/luxc/lang/translation.lux index 5b11a8e39..85eed9ba1 100644 --- a/new-luxc/source/luxc/lang/translation.lux +++ b/new-luxc/source/luxc/lang/translation.lux @@ -12,14 +12,13 @@ [host] [io] (world [file #+ File])) - (luxc ["&" base] - [";L" host] - (host [";H" macro] - ["$" jvm]) + (luxc ["&" lang] ["&;" io] - ["&;" module] - ["&;" eval] - (lang ["&;" syntax] + (lang [";L" module] + [";L" host] + (host [";H" macro] + ["$" jvm]) + ["&;" syntax] (analysis [";A" expression] [";A" common]) (synthesis [";S" expression]) @@ -27,7 +26,8 @@ [";T" statement] [";T" common] [";T" expression] - [";T" eval])) + [";T" eval]) + ["&;" eval]) )) (def: analyse @@ -160,7 +160,7 @@ [#let [init-cursor [file-name +1 +0]] output (&;with-source-code [init-cursor +0 source-code] action) - _ (&module;flag-compiled! module-name)] + _ (moduleL;flag-compiled! module-name)] (wrap output))) (def: (parse current-module) @@ -174,15 +174,15 @@ (#e;Success [(set@ #;source source' compiler) output])))) -(def: (translate-module source-dirs module-name target-dir compiler) - (-> (List File) Text File Compiler (T;Task Compiler)) +(def: (translate-module source-dirs target-dir module-name compiler) + (-> (List File) File Text Compiler (T;Task Compiler)) (do T;Monad [_ (&io;prepare-module target-dir module-name) [file-name file-content] (&io;read-module source-dirs module-name) #let [module-hash (text/hash file-content)]] (case (meta;run' compiler (do meta;Monad - [[_ artifacts _] (&module;with-module module-hash module-name + [[_ artifacts _] (moduleL;with-module module-hash module-name (commonT;with-artifacts (with-active-compilation [module-name file-name @@ -193,14 +193,10 @@ #let [[cursor _] code]] (&;with-cursor cursor (translate code)))))))] - (wrap artifacts) - ## (&module;translate-descriptor module-name) - )) - (#e;Success [compiler artifacts ## module-descriptor - ]) + (wrap artifacts))) + (#e;Success [compiler artifacts]) (do @ - [## _ (&io;write-module module-name module-descriptor) - _ (monad;map @ (function [[class-name class-bytecode]] + [_ (monad;map @ (function [[class-name class-bytecode]] (&io;write-file target-dir class-name class-bytecode)) (dict;entries artifacts))] (wrap compiler)) @@ -236,8 +232,8 @@ #;scope-type-vars (list) #;host (:! Void host)}) -(def: #export (translate-program program target sources) - (-> Text File (List File) (T;Task Unit)) +(def: #export (translate-program sources target program) + (-> (List File) File Text (T;Task Unit)) (do T;Monad [compiler (|> (case (runtimeT;translate (init-compiler (io;run hostL;init-host))) (#e;Error error) @@ -250,7 +246,7 @@ _ (&io;write-file target hostL;function-class function-bc)] (wrap compiler))) (: (T;Task Compiler)) - (:: @ map (translate-module sources prelude target)) (:: @ join) - (:: @ map (translate-module sources program target)) (:: @ join)) + (:: @ map (translate-module sources target prelude)) (:: @ join) + (:: @ map (translate-module sources target program)) (:: @ join)) #let [_ (log! "Compilation complete!")]] (wrap []))) -- cgit v1.2.3