From c2138b3ba1d49ff93bdebe9b76aca7c356b46689 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 29 May 2023 15:26:26 -0400 Subject: feat: add jit-compiled optype ; add more new commands --- forth.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'forth.c') diff --git a/forth.c b/forth.c index 0ebb7d5..cc437a2 100644 --- a/forth.c +++ b/forth.c @@ -40,6 +40,14 @@ void exec(stack *s, char *word, int len, char* line, int* i) { case directive: op->directive(s, len, line, i); break; + case compiled: + for (int i = 0; i < op->oplistlen; i++) { + if (op->oplist[i].isliteral) { + stack_push(s, op->oplist[i].literal); + } else { + (op->oplist[i].stackop)(s); + } + } } } else if (isnumber(word)) { stack_push(s, atoi(word)); @@ -67,8 +75,12 @@ void eval(stack* s, int len, char* line) { } } + int main(int argc, char** argv) { + optable_init(); + stack* s = stack_new(); + char *line = NULL; size_t len = 0; ssize_t read; -- cgit v1.2.3