about summary refs log tree commit diff stats
path: root/apps/mu.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-05-28 22:31:52 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-28 22:31:52 -0700
commit583a966d3e0b0f0e0fa9166986c877fda0643196 (patch)
treee62b31a3ed4f615330d7bf42d83a84b54e0c315f /apps/mu.subx
parent429cebf3e4c4ce5ba81443968d28b88bdfd2584e (diff)
downloadmu-583a966d3e0b0f0e0fa9166986c877fda0643196.tar.gz
6422 - size-of for handles
Diffstat (limited to 'apps/mu.subx')
-rw-r--r--apps/mu.subx11
1 files changed, 9 insertions, 2 deletions
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)
     {