hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/eval.h
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-09-19 18:53:06 +0200
committerhachem <im@hachem.wtf>2026-09-19 18:53:06 +0200
commitc6aab10e74d58fbcad723c5f074a0bb51e9f2283 (patch)
tree89d66cc61c99c4cc4b7824e3a3a2fabf3d5a674e /eval.h
parentcd2a86435e5e413630e0ab0caa48d900e49ea275 (diff)
feat: add functions with defines params and return
Diffstat (limited to 'eval.h')
-rw-r--r--eval.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/eval.h b/eval.h
index c2365cc..924ad92 100644
--- a/eval.h
+++ b/eval.h
@@ -6,6 +6,7 @@
#include <stdint.h>
#define VARIABLES_MAX 64
+#define FUNCTIONS_MAX 32
// the longest thing a single type can say when emitted
#define TEXT_LENGTH_MAX 255
@@ -23,7 +24,6 @@ enum TypeKind
KIND_VALUE
};
-// a tuple keeps what it will say, already said, so nothing inside it can go out of scope
struct Type
{
enum TypeKind kind;
@@ -38,15 +38,26 @@ struct Variable
bool declared;
};
+struct Function
+{
+ char name[NAME_LENGTH_MAX + 1];
+ const struct Node* node;
+ bool defined;
+};
+
struct Machine
{
struct Variable variables[VARIABLES_MAX];
+ struct Function functions[FUNCTIONS_MAX];
+ struct Type returned;
+ int depth;
};
enum RunStatus
{
RUN_DONE,
- RUN_FAILED
+ RUN_FAILED,
+ RUN_RETURNED
};
void machine_init(struct Machine* machine);