about summary refs log tree commit diff stats
path: root/apps/mu.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-06-13 23:15:15 -0700
committerKartik Agaram <vc@akkartik.com>2020-06-13 23:15:15 -0700
commitead3d08e774529f3026f8cd6f93b8a0d7c87ed08 (patch)
tree9e351e2f850dc547deb6b3714c74ba92c5804416 /apps/mu.subx
parent57f92a93340501c9eaecdfa1ec46eba746ee7d1a (diff)
downloadmu-ead3d08e774529f3026f8cd6f93b8a0d7c87ed08.tar.gz
6519
More fucking amateur hour.
Diffstat (limited to 'apps/mu.subx')
-rw-r--r--apps/mu.subx48
1 files changed, 47 insertions, 1 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index 2f9105d4..5b6d712f 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -1420,6 +1420,52 @@ test-convert-function-with-local-var-in-named-block:
     5d/pop-to-ebp
     c3/return
 
+test-unknown-variable-in-named-block:
+    # . prologue
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
+    # setup
+    (clear-stream _test-input-stream)
+    (clear-stream $_test-input-buffered-file->buffer)
+    (clear-stream _test-output-stream)
+    (clear-stream $_test-output-buffered-file->buffer)
+    (clear-stream _test-error-stream)
+    (clear-stream $_test-error-buffered-file->buffer)
+    # var ed/edx: exit-descriptor = tailor-exit-descriptor(16)
+    68/push 0/imm32
+    68/push 0/imm32
+    89/<- %edx 4/r32/esp
+    (tailor-exit-descriptor %edx 0x10)
+    #
+    (write _test-input-stream "fn foo {\n")
+    (write _test-input-stream "  $a: {\n")
+    (write _test-input-stream "    compare x, 0\n")
+    (write _test-input-stream "  }\n")
+    (write _test-input-stream "}\n")
+    # convert
+    (convert-mu _test-input-buffered-file _test-output-buffered-file _test-error-buffered-file %edx)
+    # registers except esp clobbered at this point
+    # restore ed
+    89/<- %edx 4/r32/esp
+    (flush _test-output-buffered-file)
+    (flush _test-error-buffered-file)
+#?     # dump _test-error-stream {{{
+#?     (write 2 "^")
+#?     (write-stream 2 _test-error-stream)
+#?     (write 2 "$\n")
+#?     (rewind-stream _test-error-stream)
+#?     # }}}
+    # check output
+    (check-stream-equal _test-output-stream  ""  "F - test-unknown-variable-in-named-block: output should be empty")
+    (check-next-stream-line-equal _test-error-stream  "unknown variable 'x'"  "F - test-unknown-variable-in-named-block: error message")
+    # check that stop(1) was called
+    (check-ints-equal *(edx+4) 2 "F - test-unknown-variable-in-named-block: exit status")
+    # don't restore from ebp
+    81 0/subop/add %esp 8/imm32
+    # . epilogue
+    5d/pop-to-ebp
+    c3/return
+
 test-always-shadow-outermost-reg-vars-in-function:
     # . prologue
     55/push-ebp
@@ -5805,7 +5851,7 @@ $parse-mu-block:check-for-named-block:
         68/push 0/imm32
         89/<- %eax 4/r32/esp
         #
-        (parse-mu-named-block %edx *(ebp+8) *(ebp+0xc) *(ebp+0x10) %eax)
+        (parse-mu-named-block %edx *(ebp+8) *(ebp+0xc) *(ebp+0x10) %eax *(ebp+0x18) *(ebp+0x1c))
         (append-to-block Heap %edi  *eax *(eax+4))
         # reclaim tmp
         81 0/subop/add %esp 8/imm32