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-06 15:03:51 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-18 00:44:48 -0700
commit1e85e8b26e9ce98b6f0144a7f8844e569f385c65 (patch)
treea3994d279285576ee430aa1f436f0b70bda1f3f0 /apps/mu.subx
parent745e48503eb49d9bf5246399032ad15fd8751798 (diff)
downloadmu-1e85e8b26e9ce98b6f0144a7f8844e569f385c65.tar.gz
mu.subx: compute-size-of-var
Diffstat (limited to 'apps/mu.subx')
-rw-r--r--apps/mu.subx14
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index e0396a6e..fdf94ed1 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -6784,17 +6784,19 @@ compute-size-of-var:  # in: (addr var) -> result/eax: int
     89/<- %ebp 4/r32/esp
     # . push 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
-    # if (t->left-is-atom == false) t = t->left
+    (lookup *(ecx+8) *(ecx+0xc))  # => eax
+    89/<- %ecx 0/r32/eax
+    # if (t->left-is-atom == false) t = lookup(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
     }
-    (compute-size-of-type-id *(ecx+4))  # Tree-left => eax
+    # TODO: ensure t is an atom
+    (compute-size-of-type-id *(ecx+4))  # Tree-value => eax
 $compute-size-of-var:end:
     # . restore registers
     59/pop-to-ecx