From b5419a1a26eee129773ef5f9599eeb6e9bd8e562 Mon Sep 17 00:00:00 2001 From: Richard Thier Date: Mon, 16 Sep 2024 23:18:32 +0200 Subject: [PATCH] improvements --- engine/slc.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/engine/slc.h b/engine/slc.h index e9409e6..a5ddbd8 100644 --- a/engine/slc.h +++ b/engine/slc.h @@ -19,6 +19,7 @@ static inline SLC_WORDTYP get_word_type(uint8_t flags) { return (SLC_WORDTYP)(flags >> 6); } +// TODO: probably should remove this? /** Gets the 6-bit variable count (at most 64 vars possible per word) */ static inline uint8_t get_word_var_count(uint8_t flags) { return (flags && 0x3F); /* 0011 1111 */ @@ -73,6 +74,7 @@ struct wordstart { uint8_t low_offset; /* char ..name[]; // The REMAINS of name of the word being defined. Can be empty! */ /* char vars[]; // The local (at least 1-letter) variables of the word. Can be empty - min 4x8bit per a var, like: " @a;" */ + // TODO: process vars when doing the reader->session store /* char newline; // there is always a newline at this point! XXX: "@a; ", "@b;\n" is how we store vars (*/ /* char data[]; // The "body" of the word - either text source or inline threaded code (at least 1 character) */ /* char ender[]; // The ender-string that ends the word - always at least 1 character! */ @@ -114,12 +116,14 @@ typedef enum SLC_IO_OP SLC_IO_OP; * SLC_SYM_GET Gets the symbol at key (the word parameter is unused). Returns NULL if there is no word for the key. * SLC_SYM_ERASE Erases the symbol table so it becomes empty again. Can never fail, returns NULL. * + * Rem.: On GET we return a wordstart* in case the key is to a word and a regular uint32_t* if its a variable name! + * * @param op Defines which operation the caller wants. * @param key The key (both for SET and GET) - * @param word When adding a found word to the symbol table, the key will point to this word + * @param ptr When adding a found word/variable to the symbol table, the key will point to this wordstart* or uint32_t* * @returns The word/var definition stored for the key, or NULL when it is not stored yet or op is SET and there was an error. */ -typedef wordstart* (*sym)(SLC_SYM_OP op, char *key, wordstart *word); +typedef void* (*sym)(SLC_SYM_OP op, char *key, void *ptr); // TODO: union for this? /** @@ -200,7 +204,6 @@ typedef uint8_t (*coderead)(); * * - words themselves (direct offset) * - variables of the words (direct offset) - * - "word ", "word(", "word[", "word{" keys show where "blocks" of that word is. TODO: what to do with multiple blocks? Use flagz? * * The code stack is what the interpreter uses for return addresses, the data stack however is FORTH-style usual stack. * The "insert_stack" collects things that we will read instead of reading the code_src AFTER a return from current word.