diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-11-26 21:46:46 -0800 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-11-26 21:46:46 -0800 |
commit | 7f40e8a3f6cb4d38885317212773985bcb2136d4 (patch) | |
tree | f4aafdb1a3020b98ae91b7b4fef59d560467a69b | |
parent | 896a353a7dadaeca02ff75a734bc2a43691f9383 (diff) | |
download | mu-7f40e8a3f6cb4d38885317212773985bcb2136d4.tar.gz |
7282
-rwxr-xr-x | apps/mu | bin | 576872 -> 578051 bytes | |||
-rw-r--r-- | apps/mu.subx | 86 |
2 files changed, 86 insertions, 0 deletions
diff --git a/apps/mu b/apps/mu index f159323b..d216c94d 100755 --- a/apps/mu +++ b/apps/mu Binary files differdiff --git a/apps/mu.subx b/apps/mu.subx index 7390edac..b2c3d165 100644 --- a/apps/mu.subx +++ b/apps/mu.subx @@ -8102,6 +8102,75 @@ test-copy-to-null-value-to-address: 5d/pop-to-ebp c3/return +test-copy-to-invalid-value-to-offset: + # . 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 x/eax: int <- copy 0\n") + (write _test-input-stream " var y: (offset int)\n") + (write _test-input-stream " copy-to y, x\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-copy-to-invalid-value-to-offset: output should be empty") + (check-next-stream-line-equal _test-error-stream "fn foo: stmt copy-to: 'y' must be a non-addr non-offset scalar" "F - test-copy-to-invalid-value-to-offset: error message") + # check that stop(1) was called + (check-ints-equal *(edx+4) 2 "F - test-copy-to-invalid-value-to-offset: exit status") + # don't restore from ebp + 81 0/subop/add %esp 8/imm32 + # . epilogue + 5d/pop-to-ebp + c3/return + +test-copy-to-null-value-to-offset: + # . 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) + # + (write _test-input-stream "fn foo {\n") + (write _test-input-stream " var y: (offset int)\n") + (write _test-input-stream " copy-to y, 0\n") + (write _test-input-stream "}\n") + # convert + (convert-mu _test-input-buffered-file _test-output-buffered-file Stderr 0) + (flush _test-output-buffered-file) + # no errors + # . epilogue + 89/<- %esp 5/r32/ebp + 5d/pop-to-ebp + c3/return + test-copy-to-deref-address: # . prologue 55/push-ebp @@ -21229,6 +21298,23 @@ $check-mu-copy-to-stmt:types: (string-equal? %eax "0") # => eax 3d/compare-eax-and 0/imm32/false 74/jump-if-= break/disp8 + e9/jump $check-mu-copy-to-stmt:end/disp32 + } + # if dest is an offset and src is 0, return + { + (lookup *edi *(edi+4)) # Stmt-var-value Stmt-var-value => eax + (lookup *(eax+8) *(eax+0xc)) # Var-type Var-type => eax + 81 7/subop/compare *eax 0/imm32/false # Type-tree-is-atom + 75/jump-if-!= break/disp8 + (lookup *(eax+4) *(eax+8)) # Type-tree-left Type-tree-left => eax + (is-simple-mu-type? %eax 7) # offset => eax + 3d/compare-eax-and 0/imm32/false + 74/jump-if-= break/disp8 + (lookup *esi *(esi+4)) # Stmt-var-value Stmt-var-value => eax + (lookup *eax *(eax+4)) # Var-name Var-name => eax + (string-equal? %eax "0") # => eax + 3d/compare-eax-and 0/imm32/false + 74/jump-if-= break/disp8 eb/jump $check-mu-copy-to-stmt:end/disp8 } # if dest is not number-like, abort |