aboutsummaryrefslogtreecommitdiffstats
path: root/forth.c
diff options
context:
space:
mode:
authordan <[email protected]>2023-05-29 15:26:26 -0400
committerdan <[email protected]>2023-05-29 15:26:26 -0400
commitc2138b3ba1d49ff93bdebe9b76aca7c356b46689 (patch)
tree4c53e16cca23852d8eef427edbffb1c0a43f70d2 /forth.c
parentb72c271d8731e1f67fdef29cd64726dfce893fe7 (diff)
downloadforth-c2138b3ba1d49ff93bdebe9b76aca7c356b46689.tar.gz
forth-c2138b3ba1d49ff93bdebe9b76aca7c356b46689.tar.bz2
forth-c2138b3ba1d49ff93bdebe9b76aca7c356b46689.zip
feat: add jit-compiled optype ; add more new commands
Diffstat (limited to 'forth.c')
-rw-r--r--forth.c12
1 files changed, 12 insertions, 0 deletions
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;