From 583a966d3e0b0f0e0fa9166986c877fda0643196 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Thu, 28 May 2020 22:31:52 -0700 Subject: 6422 - size-of for handles --- apps/mu | Bin 256130 -> 256151 bytes apps/mu.subx | 11 +++++++++-- apps/print-file.mu | 8 ++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'apps') diff --git a/apps/mu b/apps/mu index 5158562c..1f77f3b4 100755 Binary files a/apps/mu and b/apps/mu differ diff --git a/apps/mu.subx b/apps/mu.subx index 2e657c89..5bc534f1 100644 --- a/apps/mu.subx +++ b/apps/mu.subx @@ -7943,10 +7943,17 @@ size-of-type-id: # t: type-id -> result/eax: int 89/<- %ecx 4/r32/esp # eax = t 8b/-> *(ebp+8) 0/r32/eax - # if v is a literal, return 0 + # if t is a literal, return 0 3d/compare-eax-and 0/imm32 74/jump-if-= $size-of-type-id:end/disp8 # eax changes type from type-id to int - # if v has a user-defined type, return its size + # if t is a handle, return 8 + 3d/compare-eax-and 4/imm32/handle + { + 75/jump-if-!= break/disp8 + b8/copy-to-eax 8/imm32 + eb/jump $size-of-type-id:end/disp8 # eax changes type from type-id to int + } + # if t is a user-defined type, return its size # TODO: support non-atom type (find-typeinfo %eax %ecx) { diff --git a/apps/print-file.mu b/apps/print-file.mu index 5010bafb..b5b5601b 100644 --- a/apps/print-file.mu +++ b/apps/print-file.mu @@ -14,8 +14,16 @@ $main-body: { { break-if-<= var filename/edx: (addr addr array byte) <- index args 1 + var in: (handle buffered-file) + { + var addr-in/eax: (addr handle buffered-file) <- address in + open *filename, 0, addr-in + } + var in-addr/eax: (addr buffered-file) <- lookup in print-string "filename: " print-string *filename + print-string ": " + print-int32-to-screen in-addr print-string "\n" } } -- cgit 1.4.1-2-gfad0