diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-05-05 16:35:41 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-05-18 00:44:48 -0700 |
commit | df4326a6e9ed62eaba08b8cbd04506bc7632c926 (patch) | |
tree | 4c4c295007b11c309a77e847934c690a966ca532 /apps | |
parent | b1d13b806fb5fcac53edccd77407211fd89daaee (diff) | |
download | mu-df4326a6e9ed62eaba08b8cbd04506bc7632c926.tar.gz |
mu.subx: third test passing
Diffstat (limited to 'apps')
-rw-r--r-- | apps/mu.subx | 81 |
1 files changed, 57 insertions, 24 deletions
diff --git a/apps/mu.subx b/apps/mu.subx index 5c4edd8a..d90e49a6 100644 --- a/apps/mu.subx +++ b/apps/mu.subx @@ -5606,13 +5606,13 @@ lookup-var-helper: # name: (addr slice), vars: (addr stack (handle var)), out: # if v->name == name # return # curr -= 8 - # return 0 # # . prologue 55/push-ebp 89/<- %ebp 4/r32/esp # . save registers 50/push-eax + 51/push-ecx 52/push-edx 53/push-ebx 56/push-esi @@ -5630,16 +5630,29 @@ lookup-var-helper: # name: (addr slice), vars: (addr stack (handle var)), out: # var curr/ebx: (addr handle var) = &vars->data[vars->top - 8] 8d/copy-address *(esi+ebx) 3/r32/ebx { - # if (curr < min) return 0 + # if (curr < min) return 39/compare %ebx 2/r32/edx - b8/copy-to-eax 0/imm32 0f 82/jump-if-addr< break/disp32 - # var v/eax: (addr var) = lookup(*curr) + # var v/ecx: (addr var) = lookup(*curr) (lookup *ebx *(ebx+4)) # => eax - # if (v->name == name) return - (slice-equal? *(ebp+8) *eax) # Var-name + 89/<- %ecx 0/r32/eax + # var vn/eax: (addr array byte) = lookup(v->name) + (lookup *ecx *(ecx+4)) # Var-name Var-name => eax + # if (vn == name) return curr + (slice-equal? *(ebp+8) %eax) # => eax 3d/compare-eax-and 0/imm32/false - 75/jump-if-!= break/disp8 + { + 74/jump-if-= break/disp8 + # esi = out + 8b/-> *(ebp+0x10) 6/r32/esi + # *out = *curr + 8b/-> *ebx 0/r32/eax + 89/<- *esi 0/r32/eax + 8b/-> *(ebx+4) 0/r32/eax + 89/<- *(esi+4) 0/r32/eax + # return + eb/jump $lookup-var-helper:end/disp8 + } # curr -= 8 81 5/subop/subtract %ebx 8/imm32 e9/jump loop/disp32 @@ -5649,6 +5662,7 @@ $lookup-var-helper:end: 5e/pop-to-esi 5b/pop-to-ebx 5a/pop-to-edx + 59/pop-to-ecx 58/pop-to-eax # . epilogue 89/<- %esp 5/r32/ebp @@ -5744,24 +5758,43 @@ test-parse-mu-stmt: 68/push 0/imm32/top 89/<- %ecx 4/r32/esp (clear-stack %ecx) - # var v/edx: var - 81 5/subop/subtract %esp 0x14/imm32 # Var-size + # var v/edx: (handle var) + 68/push 0/imm32 + 68/push 0/imm32 89/<- %edx 4/r32/esp - (zero-out %edx 0x14) # Var-size - # v->name = "n" - c7 0/subop/copy *edx "n"/imm32 # Var-name + # var s/eax: (handle array byte) + 68/push 0/imm32 + 68/push 0/imm32 + 89/<- %eax 4/r32/esp # - (push %ecx %edx) + (copy-array Heap "n" %eax) + (new-var Heap *eax *(eax+4) %edx) + # + (push %ecx *edx) + (push %ecx *(edx+4)) + # var out/eax: (handle stmt) + 68/push 0/imm32 + 68/push 0/imm32 + 89/<- %eax 4/r32/esp # convert - (parse-mu-stmt _test-input-stream %ecx 0) # => eax - # check result - (check-ints-equal *eax 1 "F - test-parse-mu-stmt/tag") # Stmt-tag is Stmt1 - (check-strings-equal *(eax+4) "increment" "F - test-parse-mu-stmt/name") # Stmt1-operation - # edx: (handle list var) = result->inouts - 8b/-> *(eax+8) 2/r32/edx # Stmt1-inouts - # ebx: (handle var) = result->inouts->value - 8b/-> *edx 3/r32/ebx # Stmt-var-value - (check-strings-equal *ebx "n" "F - test-parse-mu-stmt/inout:0") # Var-name + (parse-mu-stmt _test-input-stream %ecx 0 %eax) + # var out-addr/edx: (addr stmt) = lookup(*out) + (lookup *eax *(eax+4)) # => eax + 89/<- %edx 0/r32/eax + # out->tag + (check-ints-equal *edx 1 "F - test-parse-mu-stmt/tag") # Stmt-tag is Stmt1 + # out->operation + (lookup *(edx+4) *(edx+8)) # Stmt1-operation Stmt1-operation => eax + (check-strings-equal %eax "increment" "F - test-parse-mu-stmt/name") # Stmt1-operation + # out->inouts->value->name + # . eax = out->inouts + (lookup *(edx+0xc) *(edx+0x10)) # Stmt1-inouts Stmt1-inouts => eax + # . eax = out->inouts->value + (lookup *eax *(eax+4)) # Stmt-var-value Stmt-var-value => eax + # . eax = out->inouts->value->name + (lookup *eax *(eax+4)) # Var-name Var-name => eax + # . + (check-strings-equal %eax "n" "F - test-parse-mu-stmt/inout:0") # . epilogue 89/<- %esp 5/r32/ebp 5d/pop-to-ebp @@ -5803,7 +5836,7 @@ test-parse-mu-stmt-with-comma: 5d/pop-to-ebp c3/return -new-var: # ad: (addr allocation-descriptor), name: (addr array byte), out: (addr handle var) +new-var: # ad: (addr allocation-descriptor), name: (handle array byte), out: (addr handle var) # . prologue 55/push-ebp 89/<- %ebp 4/r32/esp @@ -5816,7 +5849,7 @@ new-var: # ad: (addr allocation-descriptor), name: (addr array byte), out: (add (allocate *(ebp+8) *Var-size %ecx) # var out-addr/eax: (addr var) (lookup *ecx *(ecx+4)) # => eax - # out-addr->name = copy-array(name) + # out-addr->name = name 8b/-> *(ebp+0xc) 1/r32/ecx 89/<- *eax 1/r32/ecx # Var-name 8b/-> *(ebp+0x10) 1/r32/ecx |