summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcs <dcs@FreeBSD.org>2000-06-12 16:46:28 +0000
committerdcs <dcs@FreeBSD.org>2000-06-12 16:46:28 +0000
commitb91a93f851dbc2bb944fccdd0a5b28f6e901bfdc (patch)
tree7069f1dfa96b8c9a0b054f26b860c1b90219bc96
parent52e5343bd3ec4db95f886666ce4c2e6e6f864ac2 (diff)
downloadFreeBSD-src-b91a93f851dbc2bb944fccdd0a5b28f6e901bfdc.zip
FreeBSD-src-b91a93f851dbc2bb944fccdd0a5b28f6e901bfdc.tar.gz
Fix REFILL. It must throw RESTART instead of OUTOFTEXT so that
execution can take place at the point where it stopped after the input buffer has been refilled. Add ANS Forth CORE EXT and FILE word SOURCE-ID.
-rw-r--r--sys/boot/ficl/words.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/sys/boot/ficl/words.c b/sys/boot/ficl/words.c
index 8c235db..621a3f7 100644
--- a/sys/boot/ficl/words.c
+++ b/sys/boot/ficl/words.c
@@ -4156,6 +4156,24 @@ static void compareString(FICL_VM *pVM)
/**************************************************************************
+ s o u r c e - i d
+** CORE EXT, FILE ( -- 0 | -1 | fileid )
+** Identifies the input source as follows:
+**
+** SOURCE-ID Input source
+** --------- ------------
+** fileid Text file fileid
+** -1 String (via EVALUATE)
+** 0 User input device
+**************************************************************************/
+static void sourceid(FICL_VM *pVM)
+{
+ stackPushINT(pVM->pStack, pVM->sourceID.i);
+ return;
+}
+
+
+/**************************************************************************
r e f i l l
** CORE EXT ( -- flag )
** Attempt to fill the input buffer from the input source, returning a true
@@ -4170,10 +4188,16 @@ static void compareString(FICL_VM *pVM)
**************************************************************************/
static void refill(FICL_VM *pVM)
{
+ static int tries = 0;
+
FICL_INT ret = (pVM->sourceID.i == -1) ? FICL_FALSE : FICL_TRUE;
+ if (ret && tries == 0) {
+ tries = 1;
+ vmThrow(pVM, VM_RESTART);
+ }
+ if (tries == 1)
+ tries = 0;
stackPushINT(pVM->pStack, ret);
- if (ret)
- vmThrow(pVM, VM_OUTOFTEXT);
return;
}
@@ -4775,6 +4799,7 @@ void ficlCompileCore(FICL_DICT *dp)
dictAppendWord(dp, "pick", pick, FW_DEFAULT);
dictAppendWord(dp, "roll", roll, FW_DEFAULT);
dictAppendWord(dp, "refill", refill, FW_DEFAULT);
+ dictAppendWord(dp, "source-id", sourceid, FW_DEFAULT);
dictAppendWord(dp, "to", toValue, FW_IMMEDIATE);
dictAppendWord(dp, "value", constant, FW_DEFAULT);
dictAppendWord(dp, "\\", commentLine, FW_IMMEDIATE);
OpenPOWER on IntegriCloud