about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--apps/mu.subx14
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index 5ad2044e..c7c8cda2 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -6940,10 +6940,10 @@ size-of:  # v: (addr var) -> result/eax: int
     89/<- %ebp 4/r32/esp
     # . save registers
     51/push-ecx
-    # TODO
-    # var t/ecx: (handle tree type-id) = v->type
+    # var t/ecx: (addr tree type-id) = lookup(v->type)
     8b/-> *(ebp+8) 1/r32/ecx
-    8b/-> *(ecx+4) 1/r32/ecx  # Var-type
+    (lookup *(ecx+8) *(ecx+0xc))  # Var-type Var-type => eax
+    89/<- %ecx 0/r32/eax
     # if is-mu-array?(t) return size-of-array(t)
     {
       (is-mu-array? %ecx)  # => eax
@@ -6952,13 +6952,15 @@ size-of:  # v: (addr var) -> result/eax: int
       (size-of-array %ecx)  # => eax
       eb/jump $size-of:end/disp8
     }
-    # if (t->left-is-atom == false) t = t->left
+    # if (!t->is-atom?) t = t->left
     {
       81 7/subop/compare *ecx 0/imm32/false  # Tree-is-atom
       75/jump-if-!= break/disp8
-      8b/-> *(ecx+4) 1/r32/ecx  # Tree-left
+      (lookup *(ecx+4) *(ecx+8))  # Tree-left Tree-left => eax
+      89/<- %ecx 0/r32/eax
     }
-    (size-of-type-id *(ecx+4))  # Tree-left => eax
+    # TODO: assert t->is-atom?
+    (size-of-type-id *(ecx+4))  # Tree-value => eax
 $size-of:end:
     # . restore registers
     59/pop-to-ecx