aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/specification/compositor/common.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-07-15 00:45:15 -0400
committerEduardo Julian2021-07-15 00:45:15 -0400
commit0abd5bd3c0e38e352e9ba38268e04e1c858ab01e (patch)
treefe0af9e70413e9fc4f3848e0642920fca501c626 /stdlib/source/specification/compositor/common.lux
parent89ca40f2f101b2b38187eab5cf905371cd47eb57 (diff)
Re-named "spec" hierarchy to "specification".
Diffstat (limited to 'stdlib/source/specification/compositor/common.lux')
-rw-r--r--stdlib/source/specification/compositor/common.lux81
1 files changed, 81 insertions, 0 deletions
diff --git a/stdlib/source/specification/compositor/common.lux b/stdlib/source/specification/compositor/common.lux
new file mode 100644
index 000000000..ed3b53f30
--- /dev/null
+++ b/stdlib/source/specification/compositor/common.lux
@@ -0,0 +1,81 @@
+(.module:
+ [lux #*
+ [abstract
+ [monad (#+ do)]]
+ [control
+ ["." io (#+ IO)]
+ ["." try (#+ Try)]]
+ [tool
+ [compiler
+ ["." reference]
+ ["." analysis]
+ ["." synthesis (#+ Synthesis)]
+ ["." directive]
+ ["." phase
+ ["." macro (#+ Expander)]
+ ["." generation (#+ Operation)]
+ [extension (#+ Extender)
+ ["." bundle]]]
+ [default
+ ["." platform (#+ Platform)]]]]])
+
+(type: #export Runner
+ (-> Text Synthesis (Try Any)))
+
+(type: #export Definer
+ (-> Name Synthesis (Try Any)))
+
+(type: #export (Instancer what)
+ (All [anchor expression directive]
+ (-> (Platform IO anchor expression directive)
+ (generation.State+ anchor expression directive)
+ what)))
+
+(def: (runner (^slots [#platform.runtime #platform.phase #platform.host]) state)
+ (Instancer Runner)
+ (function (_ evaluation-name expressionS)
+ (do try.monad
+ [expressionG (<| (phase.run state)
+ generation.with-buffer
+ (do phase.monad
+ [_ runtime]
+ (phase expressionS)))]
+ (\ host evaluate! evaluation-name expressionG))))
+
+(def: (definer (^slots [#platform.runtime #platform.phase #platform.host])
+ state)
+ (Instancer Definer)
+ (function (_ lux-name expressionS)
+ (do try.monad
+ [definitionG (<| (phase.run state)
+ generation.with-buffer
+ (do phase.monad
+ [_ runtime
+ expressionG (phase expressionS)
+ [host-name host-value host-directive] (generation.define! lux-name expressionG)
+ _ (generation.learn lux-name host-name)]
+ (phase (synthesis.constant lux-name))))]
+ (\ host evaluate! "definer" definitionG))))
+
+(def: #export (executors target expander platform
+ analysis-bundle generation-bundle directive-bundle
+ program extender)
+ (All [anchor expression directive]
+ (-> Text Expander (Platform IO anchor expression directive)
+ analysis.Bundle
+ (generation.Bundle anchor expression directive)
+ (directive.Bundle anchor expression directive)
+ (-> expression directive) Extender
+ (IO (Try [(directive.State+ anchor expression directive)
+ Runner
+ Definer]))))
+ (do io.monad
+ [?state (platform.initialize target expander analysis-bundle platform generation-bundle directive-bundle program extender)]
+ (wrap (do try.monad
+ [[directive-bundle directive-state] ?state
+ #let [generation-state (get@ [#directive.generation
+ #directive.state]
+ directive-state)]]
+ (wrap [[directive-bundle directive-state]
+ (..runner platform generation-state)
+ (..definer platform generation-state)])))))