(.module: [lux (#- Module) [type (#+ :share)] ["@" target (#+ Host)] [abstract [monad (#+ do)]] [control ["." io (#+ IO io)] ["." try (#+ Try)] [parser [cli (#+ program:)]] [security ["!" capability]] [concurrency ["." promise (#+ Promise) ("#@." monad)]]] [data [binary (#+ Binary)] ["." product] ["." text ["%" format (#+ format)]] [collection ["." dictionary] ["." row (#+ Row)] ["." list ("#@." functor fold)]]] [time ["." instant (#+ Instant)]] [world ["." file (#+ File Path)] ["." console]] [tool [compiler ["." phase] [default ["." platform (#+ Platform)]] [language [lux ["." syntax] ["." analysis [macro (#+ Expander)]] ["." generation (#+ Buffer)] ["." directive] [phase [extension (#+ Extender)]]]] [meta [archive (#+ Archive) [descriptor (#+ Module)]] [io ["ioW" archive]]]] ## ["." interpreter] ]] ["." / #_ ["#." cli (#+ Service)] ["#." static (#+ Static)] ["#." export]]) (def: (or-crash! failure-description action) (All [a] (-> Text (Promise (Try a)) (Promise a))) (do promise.monad [?output action] (case ?output (#try.Failure error) (exec (log! (format text.new-line failure-description text.new-line error text.new-line)) (io.run (io.exit +1))) (#try.Success output) (wrap output)))) (with-expansions [ (as-is anchor expression artifact)] (def: #export (compiler static expander host-analysis platform generation-bundle host-directive-bundle program extender service packager,package) (All [] (-> Static Expander analysis.Bundle (IO (Platform )) (generation.Bundle ) (directive.Bundle ) (-> expression artifact) Extender Service [(-> (Row [Module (generation.Buffer artifact)]) Binary) Path] (Promise Any))) (do {@ promise.monad} [platform (promise.future platform) console (|> console.system promise.future (:: @ map (|>> try.assume console.async)))] (case service (#/cli.Compilation compilation) (<| (or-crash! "Compilation failed:") (do (try.with promise.monad) [#let [[compilation-sources compilation-libraries compilation-target compilation-module] compilation] [state archive] (:share [] {(Platform ) platform} {(Promise (Try [(directive.State+ ) Archive])) (:assume (platform.initialize static compilation-module expander host-analysis platform generation-bundle host-directive-bundle program extender))}) [archive state] (:share [] {(Platform ) platform} {(Promise (Try [Archive (directive.State+ )])) (:assume (platform.compile compilation-libraries static expander platform compilation [archive state]))}) _ (ioW.freeze (get@ #platform.&file-system platform) (get@ #/static.host static) (get@ #/static.target static) archive)] (wrap (log! "Compilation complete!")))) (#/cli.Export export) (<| (or-crash! "Export failed:") (do (try.with promise.monad) [_ (/export.export (get@ #platform.&file-system platform) (get@ #/static.host-module-extension static) export)] (wrap (log! "Export complete!")))) (#/cli.Interpretation interpretation) ## TODO: Fix the interpreter... (undefined) ## (<| (or-crash! "Interpretation failed:") ## (interpreter.run (try.with promise.monad) console platform interpretation generation-bundle)) ))))