aboutsummaryrefslogtreecommitdiffstats
path: root/optable.h
diff options
context:
space:
mode:
authordan <[email protected]>2023-05-29 17:16:01 -0400
committerdan <[email protected]>2023-05-29 17:16:01 -0400
commit0ba0482710f0a3300c0743a2a986e117972e6ec8 (patch)
tree09156b4ebfcf0177e883829f3ebec1525e9c64ad /optable.h
parentbf791d062597784a7f4ebc143ada4cc87d4fdebd (diff)
downloadforth-0ba0482710f0a3300c0743a2a986e117972e6ec8.tar.gz
forth-0ba0482710f0a3300c0743a2a986e117972e6ec8.tar.bz2
forth-0ba0482710f0a3300c0743a2a986e117972e6ec8.zip
refactor: optable no longer global
Diffstat (limited to 'optable.h')
-rw-r--r--optable.h13
1 files changed, 10 insertions, 3 deletions
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