aboutsummaryrefslogtreecommitdiff
path: root/lux-bootstrapper/src/lux/optimizer.clj
diff options
context:
space:
mode:
authorEduardo Julian2021-08-27 20:59:34 -0400
committerEduardo Julian2021-08-27 20:59:34 -0400
commitc5b61d2f46ac19bf511197f3a537c4be0f47df33 (patch)
treecd62d188403e9b3998ba293dc5308719a430f1fe /lux-bootstrapper/src/lux/optimizer.clj
parente814f667aed509a70bd386dcd54628929134def4 (diff)
Updates to the Ruby compiler.
Diffstat (limited to '')
-rw-r--r--lux-bootstrapper/src/lux/optimizer.clj41
1 files changed, 41 insertions, 0 deletions
diff --git a/lux-bootstrapper/src/lux/optimizer.clj b/lux-bootstrapper/src/lux/optimizer.clj
index 5910d98db..b8095fa22 100644
--- a/lux-bootstrapper/src/lux/optimizer.clj
+++ b/lux-bootstrapper/src/lux/optimizer.clj
@@ -1161,3 +1161,44 @@
[analysis]
(->> analysis
(pass-0 true)))
+
+(defn show [synthesis]
+ (|let [[[?type [_file-name _line _]] ?form] synthesis]
+ (|case ?form
+ ;; 0
+ ($bit it) `(~'$bit ~it)
+ ;; 1
+ ($nat it) `(~'$nat ~it)
+ ;; 2
+ ($int it) `(~'$int ~it)
+ ;; 3
+ ($rev it) `(~'$rev ~it)
+ ;; 4
+ ($frac it) `(~'$frac ~it)
+ ;; 5
+ ($text it) `(~'$text ~it)
+ ;; 6
+ ($variant idx is-last? value) `(~'$variant ~idx ~is-last? ~(show value))
+ ;; 7
+ ($tuple it) `[~@(&/->seq (&/|map show it))]
+ ;; 8
+ ($apply func args) `(~(show func) ~@(&/->seq (&/|map show args)))
+ ;; 9
+ ($case ?value [?pm ?bodies]) `(~'$case ~(show ?value) [?pm ?bodies])
+ ;; 10
+ ($function _register-offset arity scope captured body*) `(~'$function ~_register-offset ~arity ~(show body*))
+ ;; 11
+ ($ann value-expr type-expr) `(~'$ann ~(show value-expr) ~(show type-expr))
+ ;; 12
+ ($var (&/$Local ?idx)) `(~'$var ~?idx)
+ ;; ("captured" 3)
+ ;; ("proc" 3)
+ ;; ("loop" 3) ;; {register-offset Int, inits (List Optimized), body Optimized}
+ ;; ("iter" 2) ;; {register-offset Int, vals (List Optimized)}
+ ($let value register body) `(~'$let ~(show value) ~register ~(show body))
+ ;; ("record-get" 2)
+ ($if test then else) `(~'$if ~(show test) ~(show then) ~(show else))
+
+ _
+ (&/adt->text synthesis)
+ )))