about summary refs log tree commit diff stats
path: root/shell
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-06-22 21:25:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-06-22 21:25:04 -0700
commit59d904b4df82e96c56e6f06358ac9de278ea7d6a (patch)
tree3b1018e0b23cc0afd8514def11558efe3a0586b8 /shell
parent5997eafd461e4ea69428b6bca19941412e599ee7 (diff)
downloadmu-59d904b4df82e96c56e6f06358ac9de278ea7d6a.tar.gz
snapshot
Still a couple of failing tests before I switch gears to breaking down
symbols containing infix.
Diffstat (limited to 'shell')
-rw-r--r--shell/infix.mu35
1 files changed, 32 insertions, 3 deletions
diff --git a/shell/infix.mu b/shell/infix.mu
index 79ce0dae..f1d9d5d6 100644
--- a/shell/infix.mu
+++ b/shell/infix.mu
@@ -123,13 +123,20 @@ fn transform-infix-2 _x-ah: (addr handle cell), trace: (addr trace) {
     var first-ah/ecx: (addr handle cell) <- get x, left
     var rest-ah/esi: (addr handle cell) <- get x, right
     var rest/eax: (addr cell) <- lookup *rest-ah
-    compare rest, 0
+    {
+      var continue?/eax: boolean <- not-null-not-nil-pair? rest
+      compare continue?, 0/false
+    }
     break-if-=
 #?     draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "d", 4/fg 0/bg
+#?     dump-cell-from-cursor-over-full-screen rest-ah, 7/fg 0/bg
     var second-ah/edx: (addr handle cell) <- get rest, left
     rest-ah <- get rest, right
     var rest/eax: (addr cell) <- lookup *rest-ah
-    compare rest, 0
+    {
+      var continue?/eax: boolean <- not-null-not-nil-pair? rest
+      compare continue?, 0/false
+    }
     break-if-=
 #?     draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "e", 4/fg 0/bg
     var third-ah/ebx: (addr handle cell) <- get rest, left
@@ -194,6 +201,28 @@ fn transform-infix-2 _x-ah: (addr handle cell), trace: (addr trace) {
     # }}}
 }
 
+fn not-null-not-nil-pair? _x: (addr cell) -> _/eax: boolean {
+  var x/esi: (addr cell) <- copy _x
+  compare x, 0
+  {
+    break-if-!=
+    return 0/false
+  }
+  var x-type/eax: (addr int) <- get x, type
+  compare *x-type, 0/pair
+  {
+    break-if-=
+    return 0/false
+  }
+  var nil?/eax: boolean <- nil? x
+  compare nil?, 0/false
+  {
+    break-if-=
+    return 0/false
+  }
+  return 1/true
+}
+
 fn swap-cells a-ah: (addr handle cell), b-ah: (addr handle cell) {
   var tmp-h: (handle cell)
   var tmp-ah/eax: (addr handle cell) <- address tmp-h
@@ -223,7 +252,7 @@ fn test-infix {
   check-infix "(= (+) 3)", "(= + 3)", "F - test-infix/operator-without-args-2"
   check-infix "($+)", "$+", "F - test-infix/dollar-operator-without-args"
   check-infix "',(a + b)", "',(+ a b)", "F - test-infix/nested-quotes"
-#?   check-infix "',(+)", "',+", "F - test-infix/nested-quotes-2"
+  check-infix "',(+)", "',+", "F - test-infix/nested-quotes-2"
   check-infix "(a + b)", "(+ a b)", "F - test-infix/simple-list"
   check-infix "(a (+) b)", "(a + b)", "F - test-infix/wrapped-operator"
   check-infix "(+ a b)", "(+ a b)", "F - test-infix/prefix-operator"