about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-06-28 09:56:40 -0700
committerKartik Agaram <vc@akkartik.com>2020-06-28 10:19:02 -0700
commitbf4fbab76d08bc27b6420dca94a2b56a9b14acdf (patch)
tree6324763d383e6df230c0de507115e7dd70ba844d /apps
parent60bffdaa49000b170d365fa8217aef526301786b (diff)
downloadmu-bf4fbab76d08bc27b6420dca94a2b56a9b14acdf.tar.gz
6584
Diffstat (limited to 'apps')
-rwxr-xr-xapps/mubin331811 -> 332626 bytes
-rw-r--r--apps/mu.subx55
2 files changed, 55 insertions, 0 deletions
diff --git a/apps/mu b/apps/mu
index 9a885745..b24bb935 100755
--- a/apps/mu
+++ b/apps/mu
Binary files differdiff --git a/apps/mu.subx b/apps/mu.subx
index 9dc7ca53..ad7f6d47 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -5022,6 +5022,54 @@ test-get-with-wrong-output-type-2:
     5d/pop-to-ebp
     c3/return
 
+test-get-with-wrong-output-type-3:
+    # . 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 "  var a: t\n")
+    (write _test-input-stream "  var c/ecx: (array int) <- get a, x\n")
+    (write _test-input-stream "}\n")
+    (write _test-input-stream "type t {\n")
+    (write _test-input-stream "  x: int\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-get-with-wrong-output-type-3: output should be empty")
+    (check-next-stream-line-equal _test-error-stream  "fn foo: stmt get: output must be an address"  "F - test-get-with-wrong-output-type-3: error message")
+    # check that stop(1) was called
+    (check-ints-equal *(edx+4) 2 "F - test-get-with-wrong-output-type-3: exit status")
+    # don't restore from ebp
+    81 0/subop/add %esp 8/imm32
+    # . epilogue
+    5d/pop-to-ebp
+    c3/return
+
 test-get-with-too-few-inouts:
     # . prologue
     55/push-ebp
@@ -10392,12 +10440,19 @@ check-mu-get-stmt:  # stmt: (addr stmt), fn: (addr function), err: (addr buffere
     (lookup *eax *(eax+4))  # Stmt-var-value Stmt-var-value => eax
     89/<- %edi 0/r32/eax
     # - check output type
+    # must be in register
     (lookup *(edi+0x18) *(edi+0x1c))  # Var-register Var-register => eax
     3d/compare-eax-and 0/imm32
     0f 84/jump-if-= $check-mu-get-stmt:error-output-not-in-register/disp32
+    # must have a non-atomic type
     (lookup *(edi+8) *(edi+0xc))  # Var-type Var-type => eax
     81 7/subop/compare *eax 0/imm32/false  # Tree-is-atom
     0f 85/jump-if-!= $check-mu-get-stmt:error-output-type-not-address/disp32
+    # type must start with (addr ...)
+    (lookup *(eax+4) *(eax+8))  # Tree-left Tree-left => eax
+    (is-simple-mu-type? %eax 2)  # => eax
+    3d/compare-eax-and 0/imm32/false
+    0f 84/jump-if-= $check-mu-get-stmt:error-output-type-not-address/disp32
     # - check for too many outputs
     (lookup *(esi+0x14) *(esi+0x18))  # Stmt1-outputs Stmt1-outputs => eax
     (lookup *(eax+8) *(eax+0xc))  # Stmt-var-next Stmt-var-next => eax