Forp: fix bug when calling C->Forp

This commit is contained in:
Jeremy Penner 2019-02-04 20:59:52 -05:00
parent 0e36599524
commit 9821025def
4 changed files with 6 additions and 13 deletions

View file

@ -2,9 +2,6 @@
s" forp.log" open const LOGFILE s" forp.log" open const LOGFILE
: log-emit LOGFILE fputc ; : log-emit LOGFILE fputc ;
stdout
' log-emit task-echo !
2 const cell 2 const cell
: cells cell * ; : cells cell * ;

14
forp.c
View file

@ -294,25 +294,23 @@ void f_cdef() { // func name --
DROP(1); DROP(1);
} }
void f_docolon();
// C code must always call a colon word through f_execute()
void f_execute() { void f_execute() {
cell oldW = W; cell oldW = W;
cell oldIP = IP; cell oldIP = IP;
cell *oldRstack;
cell retIP; cell retIP;
retIP.p = NULL; retIP.p = NULL;
if (W.p->f == f_docolon) {
RPUSH(retIP); RPUSH(retIP);
oldRstack = rstack; }
W = TOP(); W = TOP();
DROP(1); DROP(1);
W.p->f(); W.p->f();
if (oldRstack == rstack) {
RPOP();
}
W = oldW; W = oldW;
IP = oldIP; IP = oldIP;
} }
void f_docolon();
void f_colonloop() { void f_colonloop() {
while (IP.p) { while (IP.p) {
cell codeptr; cell codeptr;
@ -425,9 +423,7 @@ void f_colon() {
void f_interpretword() { // codefield flags -- void f_interpretword() { // codefield flags --
if (!STATE.i || (TOP().u & F_IMMEDIATE)) { if (!STATE.i || (TOP().u & F_IMMEDIATE)) {
DROP(1); DROP(1);
W = TOP(); // w code f_execute();
DROP(1);
W.p->f();
} else { } else {
DROP(1); DROP(1);
f_comma(); f_comma();

BIN
game.exe

Binary file not shown.

BIN
game.prj

Binary file not shown.