aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/default/evaluation.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/tool/compiler/default/evaluation.lux')
-rw-r--r--stdlib/source/lux/tool/compiler/default/evaluation.lux36
1 files changed, 36 insertions, 0 deletions
diff --git a/stdlib/source/lux/tool/compiler/default/evaluation.lux b/stdlib/source/lux/tool/compiler/default/evaluation.lux
new file mode 100644
index 000000000..1f21304ca
--- /dev/null
+++ b/stdlib/source/lux/tool/compiler/default/evaluation.lux
@@ -0,0 +1,36 @@
+(.module:
+ [lux #*
+ [control
+ [monad (#+ do)]]
+ [data
+ ["." error]
+ [text
+ format]]]
+ [///
+ ["." phase
+ [analysis (#+ Operation)
+ [".A" expression]
+ ["." type]]
+ ["." synthesis
+ [".S" expression]]
+ ["." translation]]])
+
+(type: #export Eval
+ (-> Nat Type Code (Operation Any)))
+
+(def: #export (evaluator synthesis-state translation-state translate)
+ (All [anchor expression statement]
+ (-> 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))))))))