aboutsummaryrefslogtreecommitdiffstats
path: root/forthmachine.h
diff options
context:
space:
mode:
authordan <[email protected]>2023-06-02 22:04:36 -0400
committerdan <[email protected]>2023-06-02 22:04:36 -0400
commite0fcdc6e3577f8c40b019396b400928379d928b9 (patch)
tree4009df1ca50183c18de31374a368e9857ae7d666 /forthmachine.h
parent60f09fdabfe942d2cb2d2cdb1537318ff2e89e7b (diff)
downloadforth-e0fcdc6e3577f8c40b019396b400928379d928b9.tar.gz
forth-e0fcdc6e3577f8c40b019396b400928379d928b9.tar.bz2
forth-e0fcdc6e3577f8c40b019396b400928379d928b9.zip
feat: runtime defined words are compiled;
Diffstat (limited to 'forthmachine.h')
-rw-r--r--forthmachine.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/forthmachine.h b/forthmachine.h
index 8854eac..50eb4d8 100644
--- a/forthmachine.h
+++ b/forthmachine.h
@@ -20,32 +20,34 @@ typedef void (*directiveop)(forthmachine* fm, int len, char* line, int* i);
extern char* outputbuffer;
extern int outputline;
+typedef enum {
+ compileditem_stackop = 0,
+ compileditem_literal = 1,
+ compileditem_ifcontrol = 2,
+} compileditem_type;
+
typedef struct {
- bool isliteral;
+ compileditem_type type;
union {
wordop* wordop;
stackitem literal;
+ struct {
+ int jumpto;
+ };
};
} compileditem;
typedef enum {
- directive = 0,
- builtin = 1,
- script = 2,
- compiled = 3,
+ builtin = 0,
+ compiled = 1,
} optype;
struct wordop {
char* word;
optype optype;
union {
- directiveop directive;
stackop op;
struct {
- char* script;
- int scriptlen;
- };
- struct {
compileditem* oplist;
int oplistlen;
};
@@ -63,6 +65,8 @@ struct optable {
*/
wordop* optable_getop(optable* optable, char *word);
+void defineop(forthmachine* fm, char *input, int* starti);
+
optable* optable_new();
struct forthmachine {