From 0ba0482710f0a3300c0743a2a986e117972e6ec8 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 29 May 2023 17:16:01 -0400 Subject: refactor: optable no longer global --- optable.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'optable.h') diff --git a/optable.h b/optable.h index e84ad31..b378a9f 100644 --- a/optable.h +++ b/optable.h @@ -9,8 +9,10 @@ #define DEFINED_FUNC_MAX_LENGTH 1024 #define WORD_LEN_LIMIT 255 +typedef struct optable optable; + typedef void (*stackop)(stack *); -typedef void (*directiveop)(stack *, int len, char* line, int* i); +typedef void (*directiveop)(stack *, int len, char* line, int* i, optable* optable); typedef struct { bool isliteral; @@ -44,12 +46,17 @@ typedef struct { }; } wordop; +struct optable { + int len; + wordop* optable; +}; + /** * getop returns the first wordop in the optable which is called by the word given as a parameter * if none exist, returns 0 */ -wordop* getop(char *word); +wordop* optable_getop(optable* optable, char *word); -void optable_init(); +optable* optable_init(); #endif //OPTABLE_H -- cgit v1.2.3