about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-05-05 16:45:50 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-18 00:44:48 -0700
commit5a66c5dea9029d3dfffc92835adab9b292017b51 (patch)
tree14e4215f3afeb191d82f7031f0220e81ebcff78d
parentdf4326a6e9ed62eaba08b8cbd04506bc7632c926 (diff)
downloadmu-5a66c5dea9029d3dfffc92835adab9b292017b51.tar.gz
mu.subx: fourth test passing
Our four tests are exercising the following 18 primitives at least a little
bit:
  add-operation-and-inputs-to-stmt
  append-stmt-var
  lookup-var
  lookup-var-helper
  lookup-var-or-literal
  new-literal-integer
  new-reg-var-def
  new-var
  new-var-def
  new-var-from-slice
  next-mu-token
  parse-mu-stmt
  parse-mu-var-def
  parse-type
  parse-var-with-type
  pos-or-insert-slice
  pos-slice
  stmt-has-outputs?

For comparison, here are the 34 primitives in mu.subx that we've made significant
changes to since all tests passed:
  add-operation-and-inputs-to-stmt
  append-list
  append-stmt-var
  append-to-block
  convert-mu
  find-or-create-typeinfo
  find-or-create-typeinfo-fields
  find-or-create-typeinfo-output-var
  find-typeinfo
  lookup-or-define-var
  lookup-var
  lookup-var-helper
  lookup-var-or-literal
  new-block-name
  new-literal
  new-literal-integer
  new-reg-var-def
  new-var
  new-var-def
  new-var-from-slice
  next-mu-token
  parse-mu
  parse-mu-block
  parse-mu-named-block
  parse-mu-stmt
  parse-mu-var-def
  parse-type
  parse-type-tree
  parse-var-with-type
  populate-mu-function-body
  populate-mu-function-header
  pos-or-insert-slice
  pos-slice
  stmt-has-outputs?
-rw-r--r--apps/mu.subx51
1 files changed, 35 insertions, 16 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index d90e49a6..451b7bfa 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -5766,7 +5766,7 @@ test-parse-mu-stmt:
     68/push 0/imm32
     68/push 0/imm32
     89/<- %eax 4/r32/esp
-    #
+    # v = new var("n")
     (copy-array Heap "n" %eax)
     (new-var Heap *eax *(eax+4) %edx)
     #
@@ -5813,24 +5813,43 @@ test-parse-mu-stmt-with-comma:
     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
+    # v = new var("n")
+    (copy-array Heap "n" %eax)
+    (new-var Heap *eax *(eax+4) %edx)
     #
-    (push %ecx %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-with-comma/tag")  # Stmt-tag is Stmt1
-    (check-strings-equal *(eax+4) "copy-to" "F - test-parse-mu-stmt-with-comma/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-with-comma/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-with-comma/tag")  # Stmt-tag is Stmt1
+    # out->operation
+    (lookup *(edx+4) *(edx+8))  # Stmt1-operation Stmt1-operation => eax
+    (check-strings-equal %eax "copy-to" "F - test-parse-mu-stmt-with-comma/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-with-comma/inout:0")
     # . epilogue
     89/<- %esp 5/r32/ebp
     5d/pop-to-ebp