aboutsummaryrefslogtreecommitdiffstats
path: root/forthmachine.c
diff options
context:
space:
mode:
Diffstat (limited to 'forthmachine.c')
-rw-r--r--forthmachine.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/forthmachine.c b/forthmachine.c
index 6cdefb5..d831106 100644
--- a/forthmachine.c
+++ b/forthmachine.c
@@ -11,8 +11,9 @@ forthmachine* forthmachine_new(errorhandler errorhandler) {
fm->ot = optable_new(errorhandler);
fm->s = stack_new(errorhandler);
fm->outputbuffer = (char*)malloc(sizeof(char) * MAX_OUTPUT_BUFFER_SIZE);
- fm->errorhandler = errorhandler;
strcpy(fm->outputbuffer, "");
+ fm->errorhandler = errorhandler;
+ fm->lcs = stack_new(errorhandler);
return fm;
}
@@ -39,6 +40,18 @@ static void op_exec(wordop* op, forthmachine* fm) {
}
break;
}
+ case compileditem_doloopcontrol:
+ {
+ int index = stack_pop(fm->lcs);
+ int limit = stack_pop(fm->lcs);
+ index++;
+ if (index < limit) {
+ j = op->oplist[j].loopbackto - 1;
+ stack_push(fm->lcs, limit);
+ stack_push(fm->lcs, index);
+ }
+ break;
+ }
}
}
break;