#ifndef __HF__INTERPRETER_H__ #define __HF__INTERPRETER_H__ #include #include #include "hashmap.h" #include "parser.h" #include "result.h" #define HF__INTERPRETER__WORDS_CAP 23 struct hf__interpreter__word { struct hf__node *body; size_t body_len; }; extern const hf__hashmap__free_value_t hf__interpreter__word_free; #define HF__INTERPRETER__CALL_STACK_CAP_MAX 1024 struct hf__interpreter { struct hf__node *call_stack; size_t call_stack_len; size_t call_stack_cap; size_t call_stack_cap_max; struct hf__hashmap words; // struct hf__interpreter__word * int *stack; size_t stack_len; size_t stack_size; bool is_running; int exit_code; }; extern void hf__interpreter__free(struct hf__interpreter *interpreter); typedef struct hf__result (*hf__interpreter__word_func_t)( struct hf__interpreter *const, const struct hf__node *const); extern int hf__interpreter__bool_to_flag(const bool x); extern const hf__interpreter__word_func_t HF__INTERPRETER__WORD_FUNCTION[__HF__NODE_TYPE__N]; extern void hf__interpreter__stack_push(int **arr, size_t *const len, size_t *const cap, int item); extern struct hf__result hf__interpreter__run(struct hf__interpreter *const interpreter); #endif