include term-colours.4th
include defer-is.4th
-include throw-catch.4th
include float.4th
+include debugging.4th
+
defer read
defer eval
defer print
+defer collect-garbage
+
\ ------ Types ------
variable nexttype
0 nexttype !
: make-type
create nexttype @ ,
- nexttype @ 1+ nexttype !
+ 1 nexttype +!
does> @ ;
make-type fixnum-type
nextfree @ pair-type
1 nextfree +!
+
+ collect-garbage
;
: car ( pair-obj -- car-obj )
\ }}}
+\ ---- Garbage Collection ---- {{{
+
+variable gc-enabled
+false gc-enabled !
+
+: gc-enable
+ true gc-enabled ! ;
+
+: gc-disable
+ false gc-enabled ! ;
+
+: gc-enabled?
+ gc-enabled @ ;
+
+:noname
+ gc-enabled? if
+ .s ." GC!" cr
+ then
+; is collect-garbage
+
+\ }}}
+
\ ---- Pre-defined symbols ---- {{{
objvar symbol-table
bl word
count
+ \ 2dup ." Defining primitive " type ." ..." cr
+
(create-symbol)
drop symbol-type
eof? if
inc-parse-idx
- bold fg blue ." Moriturus te saluto." reset-term ." ok" cr
+ bold fg blue ." Moriturus te saluto." reset-term cr
quit
then
cr ." Welcome to scheme.forth.jl!" cr
." Use Ctrl-D to exit." cr
+
empty-parse-str
+ gc-enable
+
begin
cr bold fg green ." > " reset-term
read
+
global-env obj@ eval
+
fg cyan ." ; " print reset-term
again
;
+++ /dev/null
-\ Words implementing exception handling
-
-: catch
- execute
- type ;
-
-: throw ( addr -- )
- begin
- R> 2dup 1- ' catch =
- while
- drop
- repeat
-
- >R
-;
-
-: return-depth
- RSP@ RSP0 - 1- ;
-
-: stack-trace
- RSP0 1+ begin
- dup RSP@ <
- while
- dup @ 1- @ >name cr .name
- 1+
- repeat
-
- drop
-;
-
-: trace
- cr ." ---" cr
- ." Return stack depth:" return-depth . cr
- ." Stack trace:"
- stack-trace
- cr ." ---" cr
-
- trace
-;