back to macros; switch macroexpand to operate in place
This commit is contained in:
parent
a54c6f2ee7
commit
6df53d463c
|
@ -1,20 +1,11 @@
|
|||
fn macroexpand _in-ah: (addr handle cell), _out-ah: (addr handle cell), globals: (addr global-table), trace: (addr trace) {
|
||||
var in-ah/esi: (addr handle cell) <- copy _in-ah
|
||||
var out-ah/edi: (addr handle cell) <- copy _out-ah
|
||||
fn macroexpand expr-ah: (addr handle cell), globals: (addr global-table), trace: (addr trace) {
|
||||
# loop until convergence
|
||||
{
|
||||
macroexpand-iter in-ah, out-ah, globals, trace
|
||||
var _in/eax: (addr cell) <- lookup *in-ah
|
||||
var in/ecx: (addr cell) <- copy _in
|
||||
var out/eax: (addr cell) <- lookup *out-ah
|
||||
var done?/eax: boolean <- cell-isomorphic? in, out, trace
|
||||
compare done?, 0/false
|
||||
break-if-!=
|
||||
copy-object out-ah, in-ah
|
||||
loop
|
||||
}
|
||||
var expanded?/eax: boolean <- macroexpand-iter expr-ah, globals, trace
|
||||
compare expanded?, 0/false
|
||||
loop-if-!=
|
||||
}
|
||||
|
||||
fn macroexpand-iter _in-ah: (addr handle cell), _out-ah: (addr handle cell), globals: (addr global-table), trace: (addr trace) {
|
||||
copy-object _in-ah, _out-ah
|
||||
# return true if we found any macros
|
||||
fn macroexpand-iter _expr-ah: (addr handle cell), globals: (addr global-table), trace: (addr trace) -> _/eax: boolean {
|
||||
return 0/false
|
||||
}
|
||||
|
|
|
@ -609,16 +609,14 @@ fn run _in-ah: (addr handle gap-buffer), out: (addr stream byte), globals: (addr
|
|||
break-if-=
|
||||
return
|
||||
}
|
||||
var macroexpand-result-h: (handle cell)
|
||||
var macroexpand-result-ah/edx: (addr handle cell) <- address macroexpand-result-h
|
||||
macroexpand read-result-ah, macroexpand-result-ah, globals, trace
|
||||
macroexpand read-result-ah, globals, trace
|
||||
var nil-h: (handle cell)
|
||||
var nil-ah/eax: (addr handle cell) <- address nil-h
|
||||
allocate-pair nil-ah
|
||||
var eval-result-h: (handle cell)
|
||||
var eval-result-ah/edi: (addr handle cell) <- address eval-result-h
|
||||
debug-print "^", 4/fg, 0xc5/bg=blue-bg
|
||||
evaluate macroexpand-result-ah, eval-result-ah, *nil-ah, globals, trace, screen-cell, keyboard-cell, 1/call-number
|
||||
evaluate read-result-ah, eval-result-ah, *nil-ah, globals, trace, screen-cell, keyboard-cell, 1/call-number
|
||||
debug-print "$", 4/fg, 0xc5/bg=blue-bg
|
||||
var error?/eax: boolean <- has-errors? trace
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue