about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-05-04 20:09:07 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-05-04 20:09:07 -0700
commit5e0f4598488d5f88d60f67fa11465577b0446c87 (patch)
treecaea1f793076d226992f721310dc54f52ff76373
parent0069028dae00202642c2e79928dbd290c7138fe3 (diff)
downloadmu-5e0f4598488d5f88d60f67fa11465577b0446c87.tar.gz
.
-rw-r--r--shell/evaluate.mu11
-rw-r--r--shell/macroexpand.mu17
2 files changed, 25 insertions, 3 deletions
diff --git a/shell/evaluate.mu b/shell/evaluate.mu
index 25a82f52..6fc9f840 100644
--- a/shell/evaluate.mu
+++ b/shell/evaluate.mu
@@ -1026,9 +1026,14 @@ fn cell-isomorphic? _a: (addr cell), _b: (addr cell), trace: (addr trace) -> _/e
     trace-text trace, "eval", "=> true (numbers)"
     return 1/true
   }
-  compare b-type, 2/symbol
-  {
-    break-if-!=
+  $cell-isomorphic?:text-data: {
+    {
+      compare b-type, 2/symbol
+      break-if-=
+      compare b-type, 3/stream
+      break-if-=
+      break $cell-isomorphic?:text-data
+    }
     var b-val-ah/eax: (addr handle stream byte) <- get b, text-data
     var _b-val/eax: (addr stream byte) <- lookup *b-val-ah
     var b-val/ecx: (addr stream byte) <- copy _b-val
diff --git a/shell/macroexpand.mu b/shell/macroexpand.mu
index 018fa200..047d4dfd 100644
--- a/shell/macroexpand.mu
+++ b/shell/macroexpand.mu
@@ -1,3 +1,20 @@
 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
+  # 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
+  }
+}
+
+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
 }