diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-05-06 17:00:18 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-05-06 17:00:18 -0700 |
commit | 6df53d463c82933b84bd3d4232792a11ba251781 (patch) | |
tree | 0e09daa9471c79c1ce8d4d1cabf97bd6e550bd0b | |
parent | a54c6f2ee7bff0c7d459c4a3cede660ed02a5072 (diff) | |
download | mu-6df53d463c82933b84bd3d4232792a11ba251781.tar.gz |
back to macros; switch macroexpand to operate in place
-rw-r--r-- | shell/macroexpand.mu | 23 | ||||
-rw-r--r-- | shell/sandbox.mu | 6 |
2 files changed, 9 insertions, 20 deletions
diff --git a/shell/macroexpand.mu b/shell/macroexpand.mu index 047d4dfd..2f1cb5de 100644 --- a/shell/macroexpand.mu +++ b/shell/macroexpand.mu @@ -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 } diff --git a/shell/sandbox.mu b/shell/sandbox.mu index 85190f5f..2d77731a 100644 --- a/shell/sandbox.mu +++ b/shell/sandbox.mu @@ -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 { |