aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/compiler/default/phase/synthesis.lux
diff options
context:
space:
mode:
authorEduardo Julian2018-08-16 21:39:04 -0400
committerEduardo Julian2018-08-16 21:39:04 -0400
commit46b1f5100b13daa4225ca8a156de7be58f3d8b0a (patch)
tree6514ed78424fafc5ea74a9add40e13999a353a25 /stdlib/source/lux/compiler/default/phase/synthesis.lux
parente4c1b1645fa1a62a0bf8c90723eab7be634dd67f (diff)
Various fixes.
Diffstat (limited to 'stdlib/source/lux/compiler/default/phase/synthesis.lux')
-rw-r--r--stdlib/source/lux/compiler/default/phase/synthesis.lux64
1 files changed, 41 insertions, 23 deletions
diff --git a/stdlib/source/lux/compiler/default/phase/synthesis.lux b/stdlib/source/lux/compiler/default/phase/synthesis.lux
index da5cad094..cf29ad74b 100644
--- a/stdlib/source/lux/compiler/default/phase/synthesis.lux
+++ b/stdlib/source/lux/compiler/default/phase/synthesis.lux
@@ -310,29 +310,35 @@
(def: #export (%synthesis value)
(Format Synthesis)
(case value
- (^template [<pattern> <format>]
- (^ (<pattern> value))
- (<format> value))
- ([..bit %b]
- [..f64 %f]
- [..text %t])
-
- (^ (..i64 value))
- (%i (.int value))
-
- (^ (..variant [lefts right? content]))
- (|> (%synthesis content)
- (format (%n lefts) " " (%b right?) " ")
- (text.enclose ["(" ")"]))
-
- (^ (..tuple members))
- (|> members
- (list/map %synthesis)
- (text.join-with " ")
- (text.enclose ["[" "]"]))
+ (#Primitive primitive)
+ (case primitive
+ (^template [<pattern> <format>]
+ (<pattern> value)
+ (<format> value))
+ ([#Bit %b]
+ [#F64 %f]
+ [#Text %t])
+
+ (#I64 value)
+ (%i (.int value)))
+
+ (#Structure structure)
+ (case structure
+ (#analysis.Variant [lefts right? content])
+ (|> (%synthesis content)
+ (format (%n lefts) " " (%b right?) " ")
+ (text.enclose ["(" ")"]))
+
+ (#analysis.Tuple members)
+ (|> members
+ (list/map %synthesis)
+ (text.join-with " ")
+ (text.enclose ["[" "]"])))
(#Reference reference)
- (reference.%reference reference)
+ (|> reference
+ reference.%reference
+ (text.enclose ["(#@ " ")"]))
(#Control control)
(case control
@@ -354,8 +360,20 @@
(format (%synthesis func) " ")
(text.enclose ["(" ")"])))
- ## (%path' %synthesis ...)
- ## (#Branch branch)
+ (#Branch branch)
+ (case branch
+ (#Let input register body)
+ (|> (format (%synthesis input) " " (%n register) " " (%synthesis body))
+ (text.enclose ["(#let " ")"]))
+
+ (#If test then else)
+ (|> (format (%synthesis test) " " (%synthesis then) " " (%synthesis else))
+ (text.enclose ["(#if " ")"]))
+
+ (#Case input path)
+ (|> (format (%synthesis input) " " (%path' %synthesis path))
+ (text.enclose ["(#case " ")"])))
+
## (#Loop loop)
_
"???")