From c6aab10e74d58fbcad723c5f074a0bb51e9f2283 Mon Sep 17 00:00:00 2001 From: hachem Date: Sat, 19 Sep 2026 18:53:06 +0200 Subject: feat: add functions with defines params and return --- eval.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'eval.h') diff --git a/eval.h b/eval.h index c2365cc..924ad92 100644 --- a/eval.h +++ b/eval.h @@ -6,6 +6,7 @@ #include #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); -- cgit v1.3