1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 10:37:58 +03:00

step 8 macros

* Added macroexpand functions and special symbol

* Some changes to how AST is freed by apply_fn,
  to avoid having to shuffle the stack after a call.

7 failing tests. "rest" can return vector or list,
but should always return a list. Other errors in
-> and ->> macros seem more difficult to solve.
This commit is contained in:
Ben Dudson 2017-11-30 00:20:25 +00:00
parent 6df6dfd358
commit d00896dcad
3 changed files with 2467 additions and 3 deletions

View File

@ -1357,7 +1357,7 @@ core_rest:
je .missing_args je .missing_args
cmp al, content_nil cmp al, content_nil
je .return_nil je .empty_list
cmp al, content_pointer cmp al, content_pointer
jne .not_list jne .not_list

View File

@ -10,6 +10,7 @@ section .data
static unknown_type_string, db "#<unknown>" static unknown_type_string, db "#<unknown>"
static unknown_value_string, db "#<unknown value>" static unknown_value_string, db "#<unknown value>"
static function_type_string, db "#<function>" static function_type_string, db "#<function>"
static macro_type_string, db "#<macro>"
static nil_value_string, db "nil" static nil_value_string, db "nil"
static true_value_string, db "true" static true_value_string, db "true"
static false_value_string, db "false" static false_value_string, db "false"
@ -138,7 +139,7 @@ pr_str:
je .vector je .vector
cmp ch, container_function cmp ch, container_function
je .function je .function_or_macro
cmp ch, container_atom cmp ch, container_atom
je .atom je .atom
@ -502,12 +503,22 @@ pr_str:
ret ret
; -------------------------------- ; --------------------------------
.function: .function_or_macro:
cmp cl, maltype_macro
je .macro
; a function
mov rsi, function_type_string mov rsi, function_type_string
mov edx, function_type_string.len mov edx, function_type_string.len
call raw_to_string ; Puts a String in RAX call raw_to_string ; Puts a String in RAX
ret ret
.macro:
mov rsi, macro_type_string
mov edx, macro_type_string.len
call raw_to_string ; Puts a String in RAX
ret
; -------------------------------- ; --------------------------------
.atom: .atom:
mov rsi, [rsi + Cons.car] ; What the atom points to mov rsi, [rsi + Cons.car] ; What the atom points to

2453
nasm/step8_macros.asm Normal file

File diff suppressed because it is too large Load Diff