changeset 77:cc86e400869c

eval: Describe yeval() prototype
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 25 Aug 2019 21:44:32 +0200
parents 1ae2b63e9d65
children 626abd09ce11
files src/eval.h
diffstat 1 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/eval.h	Sun Aug 25 21:44:32 2019 +0200
@@ -0,0 +1,36 @@
+#ifndef src_eval_h
+#define src_eval_h
+
+#include <src/base/vec.h>
+
+/**
+ * @file eval.h
+ * @brief Evaluating ylisp expressions.
+ * @addtogroup execution
+ * @{
+ */
+
+/// Evaluation state passed to invocations of `yeval`.
+typedef struct {
+    /// A vector of yexpr_t that is used by called functions to take arguments from.
+    yvec_t call_stack;
+    // TODO: Maybe move value and atom tables in here? For now, it doesn't make
+    // a difference.
+} yeval_state_t;
+
+/**
+ * @brief The core of ylisp: Evaluate an expression, resulting in a new
+ * expression.
+ *
+ * The caller takes ownership of the returned expression. `yeval` does not take
+ * ownership of the supplied expression.
+ *
+ * `yeval` calls itself recursively during program execution.
+ */
+yexpr_t yeval(yeval_state_t* state, yexpr_t* expr);
+
+/**
+ * @}
+ */
+
+#endif