aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/default/evaluation.lux
diff options
context:
space:
mode:
authorEduardo Julian2019-03-02 23:57:30 -0400
committerEduardo Julian2019-03-02 23:57:30 -0400
commit8dfd0e3992f5ae60d568793a6843dc9fb472eba7 (patch)
treeb1e188f6631856219e6109c04eba036575cb0192 /stdlib/source/lux/tool/compiler/default/evaluation.lux
parentd117adb8fd8869cdff9c9ba0f9e5f14304c285d8 (diff)
Partially factored-out the macro-expansion machinery.
Diffstat (limited to 'stdlib/source/lux/tool/compiler/default/evaluation.lux')
-rw-r--r--stdlib/source/lux/tool/compiler/default/evaluation.lux29
1 files changed, 16 insertions, 13 deletions
diff --git a/stdlib/source/lux/tool/compiler/default/evaluation.lux b/stdlib/source/lux/tool/compiler/default/evaluation.lux
index 1f21304ca..68fda1e7d 100644
--- a/stdlib/source/lux/tool/compiler/default/evaluation.lux
+++ b/stdlib/source/lux/tool/compiler/default/evaluation.lux
@@ -10,7 +10,8 @@
["." phase
[analysis (#+ Operation)
[".A" expression]
- ["." type]]
+ ["." type]
+ [macro (#+ Expander)]]
["." synthesis
[".S" expression]]
["." translation]]])
@@ -18,19 +19,21 @@
(type: #export Eval
(-> Nat Type Code (Operation Any)))
-(def: #export (evaluator synthesis-state translation-state translate)
+(def: #export (evaluator expander synthesis-state translation-state translate)
(All [anchor expression statement]
- (-> synthesis.State+
+ (-> Expander
+ synthesis.State+
(translation.State+ anchor expression statement)
(translation.Phase anchor expression statement)
Eval))
- (function (eval count type exprC)
- (do phase.monad
- [exprA (type.with-type type
- (expressionA.compile exprC))]
- (phase.lift (do error.monad
- [exprS (|> exprA expressionS.phase (phase.run synthesis-state))]
- (phase.run translation-state
- (do phase.monad
- [exprO (translate exprS)]
- (translation.evaluate! (format "eval" (%n count)) exprO))))))))
+ (let [analyze (expressionA.phase expander)]
+ (function (eval count type exprC)
+ (do phase.monad
+ [exprA (type.with-type type
+ (analyze exprC))]
+ (phase.lift (do error.monad
+ [exprS (|> exprA expressionS.phase (phase.run synthesis-state))]
+ (phase.run translation-state
+ (do phase.monad
+ [exprO (translate exprS)]
+ (translation.evaluate! (format "eval" (%n count)) exprO)))))))))