Function calling

This commit is contained in:
2025-12-06 11:50:42 +11:00
parent 571d3bcc34
commit 9553934db5
6 changed files with 100 additions and 39 deletions

View File

@@ -7,7 +7,7 @@
#include "include/uthash.h"
typedef enum GroundRuntimeError {
ARG_TYPE_MISMATCH, TOO_FEW_ARGS, TOO_MANY_ARGS, UNKNOWN_LABEL, UNKNOWN_VARIABLE, LIST_ERROR, STRING_ERROR, MATH_ERROR, FIXME
ARG_TYPE_MISMATCH, TOO_FEW_ARGS, TOO_MANY_ARGS, UNKNOWN_LABEL, UNKNOWN_VARIABLE, LIST_ERROR, STRING_ERROR, MATH_ERROR, RETURN_TYPE_MISMATCH, FIXME
} GroundRuntimeError;
typedef struct GroundLabel {
@@ -22,28 +22,9 @@ typedef struct GroundVariable {
UT_hash_handle hh;
} GroundVariable;
typedef struct GroundFunctionArgs {
GroundValueType type;
char* name;
} GroundFunctionArgs;
typedef struct GroundFunction {
GroundFunctionArgs* args;
size_t argSize;
GroundValueType returnType;
GroundProgram program;
} GroundFunction;
typedef struct GroundFunctionWrapper {
char id[MAX_ID_LEN];
GroundFunction function;
UT_hash_handle hh;
} GroundFunctionWrapper;
typedef struct GroundScope {
GroundLabel** labels;
GroundVariable** variables;
GroundFunctionWrapper** functions;
} GroundScope;
GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope);