diff options
author | Eduardo Julian | 2021-08-27 20:59:34 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-08-27 20:59:34 -0400 |
commit | c5b61d2f46ac19bf511197f3a537c4be0f47df33 (patch) | |
tree | cd62d188403e9b3998ba293dc5308719a430f1fe /lux-bootstrapper | |
parent | e814f667aed509a70bd386dcd54628929134def4 (diff) |
Updates to the Ruby compiler.
Diffstat (limited to 'lux-bootstrapper')
-rw-r--r-- | lux-bootstrapper/src/lux/analyser.clj | 4 | ||||
-rw-r--r-- | lux-bootstrapper/src/lux/analyser/lux.clj | 11 | ||||
-rw-r--r-- | lux-bootstrapper/src/lux/compiler/jvm.clj | 2 | ||||
-rw-r--r-- | lux-bootstrapper/src/lux/optimizer.clj | 41 |
4 files changed, 49 insertions, 9 deletions
diff --git a/lux-bootstrapper/src/lux/analyser.clj b/lux-bootstrapper/src/lux/analyser.clj index ae16eb42c..e139e085f 100644 --- a/lux-bootstrapper/src/lux/analyser.clj +++ b/lux-bootstrapper/src/lux/analyser.clj @@ -114,7 +114,7 @@ (&/$Item ?value (&/$End))) parameters] (&/with-analysis-meta location exo-type - (&&lux/analyse-type-check analyse eval! exo-type ?type ?value))) + (&&lux/analyse-type-check analyse optimize eval! exo-type ?type ?value))) "lux type check type" (|let [(&/$Item ?value (&/$End)) parameters] @@ -125,7 +125,7 @@ (&/$Item ?value (&/$End))) parameters] (&/with-analysis-meta location exo-type - (&&lux/analyse-type-as analyse eval! exo-type ?type ?value))) + (&&lux/analyse-type-as analyse optimize eval! exo-type ?type ?value))) "lux def" (|let [(&/$Item [_ (&/$Identifier "" ?name)] diff --git a/lux-bootstrapper/src/lux/analyser/lux.clj b/lux-bootstrapper/src/lux/analyser/lux.clj index 857f65e00..769b85e30 100644 --- a/lux-bootstrapper/src/lux/analyser/lux.clj +++ b/lux-bootstrapper/src/lux/analyser/lux.clj @@ -705,19 +705,18 @@ (&&/|meta new-type _location _analysis))) -(defn analyse-type-check [analyse eval! exo-type ?type ?value] +(defn analyse-type-check [analyse optimize eval! exo-type ?type ?value] (|do [=type (&&/analyse-1 analyse &type/Type ?type) - ==type (eval! =type) + ==type (eval! (optimize =type)) _ (&type/check exo-type ==type) =value (&&/analyse-1 analyse ==type ?value) _location &/location] (return (&/|list (&&/|meta ==type _location - (&&/$ann =value =type) - ))))) + (&&/$ann =value =type)))))) -(defn analyse-type-as [analyse eval! exo-type ?type ?value] +(defn analyse-type-as [analyse optimize eval! exo-type ?type ?value] (|do [=type (&&/analyse-1 analyse &type/Type ?type) - ==type (eval! =type) + ==type (eval! (optimize =type)) _ (&type/check exo-type ==type) =value (&&/analyse-1+ analyse ?value)] (return (&/|list (coerce ==type =value))))) diff --git a/lux-bootstrapper/src/lux/compiler/jvm.clj b/lux-bootstrapper/src/lux/compiler/jvm.clj index d5c490a97..7a547dcd3 100644 --- a/lux-bootstrapper/src/lux/compiler/jvm.clj +++ b/lux-bootstrapper/src/lux/compiler/jvm.clj @@ -113,7 +113,7 @@ (&&proc-common/compile-proc (partial compile-expression $begin) ?proc-category ?proc-name ?args special-args)) _ - (assert false (prn-str 'compile-expression (&/adt->text syntax))) + (assert false (prn-str 'compile-expression (&o/show syntax))) )) )) 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) + ))) |