objvar symbol-table
: duplicate-charlist ( charlist -- copy )
- 2dup nil objeq? false = if
+ nil? false = if
2dup car 2swap cdr recurse cons
then ;
: get-vars-vals ( var env -- vars? vals? bool )
begin
- 2dup nil objeq? false =
+ nil? false =
while
2over 2over first-frame
get-vars-vals-frame if
car cdr
exit
then
+
+ cdr
repeat
+
+ 2swap 2drop
;
: make-macro ( name_symbol params body env -- )
set-cdr!
exit
then
+
+ cdr
repeat
2drop
: if-alternative ( ifobj -- alt|false )
cdr cdr cdr
- 2dup nil objeq? if
+ nil? if
2drop false
else
car
2swap ( env explist )
\ Abort on empty list
- 2dup nil objeq? if
+ nil? if
2drop none
2swap exit
then
begin
2dup cdr ( env explist nextexplist )
- 2dup nil objeq? false =
+ nil? false =
while
-2rot car 2over ( nextexplist env exp env )
eval
2over 2over ( env exp env exp )
operator 2dup ( env exp env opname opname )
- lookup-macro 2dup nil objeq? if
+ lookup-macro nil? if
\ Regular function application
2drop ( env exp env opname )
else
\ Macro function evaluation
+ ." Macro eval"
+
( env exp env opname mproc )
- 2swap 2drop -2rot 2drop ( env mproc exp )
- apply 2swap ( expanded-exp env )
+ 2swap 2drop -2rot 2drop cdr ( env mproc body )
- ['] eval goto-deferred
+ \ TODO: evaluate macro procedure on expression body
+ ." ABORTED: Macros not yet fully implemented!" abort
then
exit
then
arg-count-error
then
else
- -rot 2dup nil objeq? if
+ -rot nil? if
arg-count-error
then
dup 2swap ( origaddr addr charlist )
begin
- 2dup nil objeq? false =
+ nil? false =
while
2dup cdr 2swap car
drop ( origaddr addr charlist char )