aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2023-11-25 07:03:06 -0500
committerClyne Sullivan <clyne@bitgloo.com>2023-11-25 07:03:06 -0500
commit454d7a339521d250222372ffe8745c296028dee9 (patch)
treedbca41a7a7bbd4c559e990ea3c9f5ddc2251de91
parentbbff2c86a173d7ff65ef7a378c8de7de62af9f9b (diff)
add MOVE, FILL, ENVIRONMENT?, ACCEPT, RECURSE
-rw-r--r--Makefile2
-rw-r--r--core.fth25
-rw-r--r--source/core.cpp2
3 files changed, 27 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index dbc8c10..434f49f 100644
--- a/Makefile
+++ b/Makefile
@@ -22,5 +22,5 @@ clean:
sprit: source/libsprit.a
source/libsprit.a: $(OBJ)
- $(AR) rcu $@ $^
+ $(AR) rc $@ $^
diff --git a/core.fth b/core.fth
index d55f71a..0650811 100644
--- a/core.fth
+++ b/core.fth
@@ -111,4 +111,27 @@
swap postpone literal postpone literal ; imm
: ." postpone s" state @ if ['] type compile, else type then ; imm
-." hello world"
+: move dup 0 <= if drop 2drop exit then
+ >r 2dup < r> swap if
+ 1- 0 swap do over i + c@ over i + c! -1 +loop
+ else
+ 0 do over i + c@ over i + c! loop
+ then 2drop ;
+: fill -rot begin dup 0 > while
+ >r 2dup c! char+ r> 1- repeat
+ 2drop drop ;
+
+: environment? 2drop 1 0= ;
+
+: accept over >r begin dup 0 > while
+ key dup 32 < if 2drop 0
+ else dup emit rot 2dup c! char+ swap drop swap 1- then
+ repeat drop r> - [ 1 chars ] literal / ;
+
+: recurse _compxt @ compile, ; imm
+
+: fib ( n1 -- n2 ) dup 1 > if 1- dup 1- recurse swap recurse + then ;
+
+: fibs 10 0 do i fib . loop cr ;
+
+fibs ." hello world"
diff --git a/source/core.cpp b/source/core.cpp
index 52dbcbb..c5d7f28 100644
--- a/source/core.cpp
+++ b/source/core.cpp
@@ -147,6 +147,8 @@ void colon()
// The actual function list will begin one Cell beyond here.
comma(HERE + sizeof(Cell));
+ DICT[DIdxCompXt] = *SP - 2 * sizeof(Cell);
+
// Enter compiling state.
STATE = -1;
}