diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-05-06 20:36:13 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-05-18 00:44:48 -0700 |
commit | c1adafaca9597113d668e688f44ed51afdf091e2 (patch) | |
tree | dbcccfd43ad5ef769d8d754db98440aa9f2ab0a8 /apps | |
parent | d41c09a1e16e72ab55f8199ef492c1bcc4c9dc45 (diff) | |
download | mu-c1adafaca9597113d668e688f44ed51afdf091e2.tar.gz |
mu.subx: size-of
Diffstat (limited to 'apps')
-rw-r--r-- | apps/mu.subx | 14 |
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 |