aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/tool/compiler/phase')
-rw-r--r--stdlib/source/lux/tool/compiler/phase/extension/statement.lux28
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation.lux49
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/js/loop.lux4
-rw-r--r--stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux2
4 files changed, 42 insertions, 41 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/extension/statement.lux b/stdlib/source/lux/tool/compiler/phase/extension/statement.lux
index 18bb58fbd..4f36ef89f 100644
--- a/stdlib/source/lux/tool/compiler/phase/extension/statement.lux
+++ b/stdlib/source/lux/tool/compiler/phase/extension/statement.lux
@@ -36,12 +36,11 @@
Synthesis
(Operation anchor expression statement [Type expression Any])))
(////statement.lift-generation
- (///generation.with-buffer
- (do ///.monad
- [codeT (generate codeS)
- count ///generation.next
- codeV (///generation.evaluate! (format "evaluate" (%n count)) codeT)]
- (wrap [code//type codeT codeV])))))
+ (do ///.monad
+ [codeT (generate codeS)
+ count ///generation.next
+ codeV (///generation.evaluate! (format "evaluate" (%n count)) codeT)]
+ (wrap [code//type codeT codeV]))))
(def: (evaluate! type codeC)
(All [anchor expression statement]
@@ -71,11 +70,11 @@
Synthesis
(Operation anchor expression statement [Type expression Text Any])))
(////statement.lift-generation
- (///generation.with-buffer
- (do ///.monad
- [codeT (generate codeS)
- codeN+V (///generation.define! name codeT)]
- (wrap [code//type codeT codeN+V])))))
+ (do ///.monad
+ [codeT (generate codeS)
+ [target-name value statement] (///generation.define! name codeT)
+ _ (///generation.save! name statement)]
+ (wrap [code//type codeT target-name value]))))
(def: (definition name ?type codeC)
(All [anchor expression statement]
@@ -270,10 +269,9 @@
(-> expression statement)
Synthesis
(///generation.Operation anchor expression statement Any)))
- (///generation.with-buffer
- (do ///.monad
- [programG (generate programS)]
- (///generation.save! ["" ""] (program programG)))))
+ (do ///.monad
+ [programG (generate programS)]
+ (///generation.save! ["" ""] (program programG))))
(def: (def::program program)
(All [anchor expression statement]
diff --git a/stdlib/source/lux/tool/compiler/phase/generation.lux b/stdlib/source/lux/tool/compiler/phase/generation.lux
index 3fe3f867b..203c5d4ab 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation.lux
@@ -19,14 +19,6 @@
[//
[synthesis (#+ Synthesis)]]])
-(do-template [<name>]
- [(exception: #export (<name>)
- "")]
-
- [no-active-buffer]
- [no-anchor]
- )
-
(exception: #export (cannot-interpret {error Text})
(exception.report
["Error" error]))
@@ -61,19 +53,19 @@
evaluate!)
(: (-> Text statement (Error Any))
execute!)
- (: (-> Name expression (Error [Text Any]))
+ (: (-> Name expression (Error [Text Any statement]))
define!))
(type: #export (Buffer statement) (Row [Name statement]))
-(type: #export (Outputs statement) (Dictionary Path (Buffer statement)))
+(type: #export (Output statement) (Dictionary Path (Buffer statement)))
(type: #export (State anchor expression statement)
{#context Context
#anchor (Maybe anchor)
#host (Host expression statement)
#buffer (Maybe (Buffer statement))
- #outputs (Outputs statement)
+ #output (Output statement)
#counter Nat
#name-cache (Dictionary Name Text)})
@@ -97,7 +89,7 @@
#anchor #.None
#host host
#buffer #.None
- #outputs (dictionary.new text.hash)
+ #output (dictionary.new text.hash)
#counter 0
#name-cache (dictionary.new name.hash)})
@@ -122,10 +114,14 @@
(extension.read (|>> (get@ #context)
(get@ #scope-name))))
+(def: #export empty-buffer Buffer row.empty)
+
(do-template [<tag>
<with-declaration> <with-type> <with-value>
- <get> <get-type> <exception>]
- [(def: #export <with-declaration>
+ <set> <get> <get-type> <exception>]
+ [(exception: #export <exception>)
+
+ (def: #export <with-declaration>
(All [anchor expression statement output] <with-type>)
(function (_ body)
(function (_ [bundle state])
@@ -146,27 +142,34 @@
(#error.Success [stateE output])
#.None
- (exception.throw <exception> []))))]
+ (exception.throw <exception> []))))
+
+ (def: #export (<set> value)
+ (All [anchor expression statement]
+ (-> <get-type> (Operation anchor expression statement Any)))
+ (function (_ [bundle state])
+ (#error.Success [[bundle (set@ <tag> (#.Some value) state)]
+ []])))]
[#anchor
(with-anchor anchor)
(-> anchor (Operation anchor expression statement output)
(Operation anchor expression statement output))
anchor
- anchor anchor no-anchor]
+ set-anchor anchor anchor no-anchor]
[#buffer
with-buffer
(-> (Operation anchor expression statement output)
(Operation anchor expression statement output))
- row.empty
- buffer (Buffer statement) no-active-buffer]
+ ..empty-buffer
+ set-buffer buffer (Buffer statement) no-active-buffer]
)
-(def: #export outputs
+(def: #export output
(All [anchor expression statement]
- (Operation anchor expression statement (Outputs statement)))
- (extension.read (get@ #outputs)))
+ (Operation anchor expression statement (Output statement)))
+ (extension.read (get@ #output)))
(def: #export next
(All [anchor expression statement]
@@ -194,7 +197,7 @@
(def: #export (define! name code)
(All [anchor expression statement]
- (-> Name expression (Operation anchor expression statement [Text Any])))
+ (-> Name expression (Operation anchor expression statement [Text Any statement])))
(function (_ (^@ stateE [bundle state]))
(case (:: (get@ #host state) define! name code)
(#error.Success output)
@@ -224,7 +227,7 @@
(-> Path (Operation anchor expression statement Any)))
(do //.monad
[buffer ..buffer]
- (extension.update (update@ #outputs (dictionary.put target buffer)))))
+ (extension.update (update@ #output (dictionary.put target buffer)))))
(def: #export (remember lux-name)
(All [anchor expression statement]
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/js/loop.lux b/stdlib/source/lux/tool/compiler/phase/generation/js/loop.lux
index e0ec074d3..d905db9a2 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/js/loop.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/js/loop.lux
@@ -7,7 +7,7 @@
["." text
format]
[collection
- ["." list ("#;." functor)]]]
+ ["." list ("#@." functor)]]]
[host
["_" js (#+ Computation Var)]]]
["." // #_
@@ -29,7 +29,7 @@
#let [closure (_.function @scope
(|> initsS+
list.enumerate
- (list;map (|>> product.left (n/+ start) //case.register)))
+ (list@map (|>> product.left (n/+ start) //case.register)))
(_.return bodyO))]]
(wrap (_.apply/* closure initsO+))))
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux b/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux
index 5e2da39de..cb65b8b85 100644
--- a/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux
+++ b/stdlib/source/lux/tool/compiler/phase/generation/js/runtime.lux
@@ -743,7 +743,7 @@
runtime//array
))
-(def: #export artifact Text (format prefix ".js"))
+(def: #export artifact Text prefix)
(def: #export generate
(Operation Any)