about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-04-23 18:46:10 -0700
committerKartik Agaram <vc@akkartik.com>2020-05-18 00:44:47 -0700
commit286fe171c269c4e21a52182ba4cf5d9f47bad482 (patch)
tree50f10332c58bd48e4894e5dd123cc8be01fd87aa
parent233f5f7672ad828a62ed2c0f3f8d13d6d6e6d227 (diff)
downloadmu-286fe171c269c4e21a52182ba4cf5d9f47bad482.tar.gz
mu.subx: partial parse-var-with-type
-rw-r--r--apps/mu.subx17
1 files changed, 11 insertions, 6 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index b82bd45a..856244af 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -3692,6 +3692,7 @@ parse-var-with-type:  # name: (addr slice), first-line: (addr stream byte), out:
     55/push-ebp
     89/<- %ebp 4/r32/esp
     # . save registers
+    50/push-eax
     51/push-ecx
     52/push-edx
     53/push-ebx
@@ -3719,16 +3720,21 @@ $parse-var-with-type:create-var:
     (new-var-from-slice Heap %ecx *(ebp+0x10))
     # save out->register
 $parse-var-with-type:save-register:
-    # s = next-token(...)
+    # . var out-addr/edi: (addr var) = lookup(out)
+    8b/-> *(ebp+0x10) 7/r32/edi
+    (lookup *edi *(edi+4))  # => eax
+    89/<- %edi 0/r32/eax
+    # . s = next-token(...)
     (next-token-from-slice *(ecx+4) *(esi+4) 0x2f %ecx)  # s->end, name->end, '/'
-    # if (!slice-empty?(s)) out->register = slice-to-string(s)
+    # . if (!slice-empty?(s)) out->register = slice-to-string(s)
     {
 $parse-var-with-type:write-register:
       (slice-empty? %ecx)  # => eax
       3d/compare-eax-and 0/imm32/false
       75/jump-if-!= break/disp8
+      # TODO: handle from here
       (slice-to-string Heap %ecx)
-      89/<- *(edi+0x10) 0/r32/eax  # Var-register
+      89/<- *(edi+0x18) 0/r32/eax  # Var-register
     }
 $parse-var-with-type:save-type:
     (parse-type Heap *(ebp+0xc))  # => eax
@@ -3736,10 +3742,8 @@ $parse-var-with-type:save-type:
 #?     (print-int32-buffered Stderr %edi)
 #?     (write-buffered Stderr Newline)
 #?     (flush Stderr)
-    89/<- *(edi+4) 0/r32/eax  # Var-type
+    89/<- *(edi+8) 0/r32/eax  # Var-type
 $parse-var-with-type:end:
-    # return result
-    89/<- %eax 7/r32/edi
     # . reclaim locals
     81 0/subop/add %esp 8/imm32
     # . restore registers
@@ -3748,6 +3752,7 @@ $parse-var-with-type:end:
     5b/pop-to-ebx
     5a/pop-to-edx
     59/pop-to-ecx
+    58/pop-to-eax
     # . epilogue
     89/<- %esp 5/r32/ebp
     5d/pop-to-ebp