aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux/tool/compiler/default/platform.lux24
-rw-r--r--stdlib/source/lux/tool/compiler/meta/packager/js.lux (renamed from stdlib/source/lux/tool/compiler/meta/packager/script.lux)19
-rw-r--r--stdlib/source/program/compositor.lux20
3 files changed, 39 insertions, 24 deletions
diff --git a/stdlib/source/lux/tool/compiler/default/platform.lux b/stdlib/source/lux/tool/compiler/default/platform.lux
index 4ed6d6d42..04937092a 100644
--- a/stdlib/source/lux/tool/compiler/default/platform.lux
+++ b/stdlib/source/lux/tool/compiler/default/platform.lux
@@ -24,7 +24,7 @@
[macro (#+ Expander)]
## TODO: Get rid of this import ASAP
[extension (#+)]
- ["." generation]
+ ["." generation (#+ Buffer)]
[analysis
["." module]]]
[meta
@@ -67,8 +67,26 @@
(///directive.Bundle anchor expression directive)
(-> expression directive)
(! (Try <State+>))))
- (|> platform
- (get@ #runtime)
+ (|> (do ///phase.monad
+ [_ (:share [anchor expression directive]
+ {(///directive.Bundle anchor expression directive)
+ host-directive-bundle}
+ {(generation.Operation anchor expression directive Any)
+ (generation.set-buffer (:share [anchor expression directive]
+ {(///directive.Bundle anchor expression directive)
+ host-directive-bundle}
+ {(Buffer directive)
+ generation.empty-buffer}))})
+ _ (:share [anchor expression directive]
+ {(///directive.Bundle anchor expression directive)
+ host-directive-bundle}
+ {(generation.Operation anchor expression directive Any)
+ (get@ #runtime platform)})]
+ (:share [anchor expression directive]
+ {(///directive.Bundle anchor expression directive)
+ host-directive-bundle}
+ {(generation.Operation anchor expression directive Any)
+ (generation.save-buffer! "")}))
///directive.lift-generation
(///phase.run' (//init.state target
expander
diff --git a/stdlib/source/lux/tool/compiler/meta/packager/script.lux b/stdlib/source/lux/tool/compiler/meta/packager/js.lux
index 8e7988f37..e4c52af5a 100644
--- a/stdlib/source/lux/tool/compiler/meta/packager/script.lux
+++ b/stdlib/source/lux/tool/compiler/meta/packager/js.lux
@@ -1,7 +1,8 @@
(.module:
[lux #*
[control
- [pipe (#+ case>)]]
+ [pipe (#+ case>)]
+ ["." function]]
[data
[binary (#+ Binary)]
["." product]
@@ -18,21 +19,15 @@
[generation (#+ Output)]]]]])
(def: #export (package outputs)
- (All [statements]
- (-> (Output statements) Binary))
+ (-> (Output _.Statement) Binary)
(|> outputs
row.to-list
- (list@map (function (_ [module buffer])
- (|> buffer
- row.to-list
- (:coerce (List [Name _.Statement]))
- (list@map product.right))))
+ (list@map (|>> product.right
+ row.to-list
+ (list@map product.right)))
list@join
(case> (#.Cons head tail)
- (|> (list@fold (function (_ post! pre!)
- (_.then pre! post!))
- head
- tail)
+ (|> (list@fold (function.flip _.then) head tail)
(: _.Statement)
_.code
encoding.to-utf8)
diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux
index 1725e80e5..b9b2995ad 100644
--- a/stdlib/source/program/compositor.lux
+++ b/stdlib/source/program/compositor.lux
@@ -11,6 +11,7 @@
[security
["!" capability]]]
[data
+ [binary (#+ Binary)]
["." product]
["." text
["%" format (#+ format)]]
@@ -21,7 +22,7 @@
[time
["." instant (#+ Instant)]]
[world
- ["." file (#+ File)]
+ ["." file (#+ File Path)]
["." console]]
[tool
[compiler
@@ -34,9 +35,7 @@
["." platform (#+ Platform)]
["." syntax]]
[meta
- ["." archive (#+ Archive)]
- [packager
- ["." script]]]]
+ ["." archive (#+ Archive)]]]
## ["." interpreter]
]]
[/
@@ -57,10 +56,11 @@
(#try.Success output)
(wrap output))))
-(def: (save-artifacts! system state)
+(def: (save-artifacts! system state [packager package])
(All [anchor expression directive]
(-> (file.System IO)
(directive.State+ anchor expression directive)
+ [(-> (generation.Output directive) Binary) Path]
(IO (Try Any))))
(let [?outcome (phase.run' state
(:share [anchor expression directive]
@@ -73,13 +73,14 @@
(#try.Success [state output])
(do (try.with io.monad)
[file (: (IO (Try (File IO)))
- (file.get-file io.monad system "program.js"))]
- (!.use (:: file over-write) (script.package output)))
+ (file.get-file io.monad system package))]
+ (!.use (:: file over-write) (packager output)))
(#try.Failure error)
(:: io.monad wrap (#try.Failure error)))))
-(def: #export (compiler target partial-host-extension expander host-analysis platform generation-bundle host-directive-bundle program service)
+(def: #export (compiler target partial-host-extension expander host-analysis platform generation-bundle host-directive-bundle program service
+ packager,package)
(All [anchor expression directive]
(-> Text
Text
@@ -90,6 +91,7 @@
(directive.Bundle anchor expression directive)
(-> expression directive)
Service
+ [(-> (generation.Output directive) Binary) Path]
(IO Any)))
(do io.monad
[platform platform
@@ -108,7 +110,7 @@
platform}
{(IO (Try [Archive (directive.State+ anchor expression directive)]))
(platform.compile partial-host-extension expander platform configuration archive.empty state)})
- _ (save-artifacts! (get@ #platform.&file-system platform) state)
+ _ (save-artifacts! (get@ #platform.&file-system platform) state packager,package)
## _ (cache/io.clean target ...)
]
(wrap (log! "Compilation complete!"))))