about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/mu.subx80
1 files changed, 62 insertions, 18 deletions
diff --git a/apps/mu.subx b/apps/mu.subx
index b69dd57e..194b0407 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -1791,22 +1791,32 @@ next-mu-token:  # in: (addr stream byte), out: (addr slice)
     #   while true
     #     if in->read >= in->write
     #       break
-    #     var c/eax: byte = in->data[in->read]
-    #     if c == ' '
+    #     curr-byte = in->data[in->read]
+    #     if curr-byte == ' '
     #       break
-    #     if c == '('
+    #     if curr-byte == '('
     #       break
-    #     if c == ')'
+    #     if curr-byte == ')'
     #       break
-    #     ++in->read
-    #     # hack: skip a few trailing delimiters, because we don't always use
-    #     # this correct tokenizer
-    #     if c == ':'
+    #     if curr-byte == ':'
     #       break
-    #     if c == ','
+    #     if curr-byte == ','
     #       break
+    #     ++in->read
     # done:
     #   out->end = &in->data[in->read]
+    #   # hack: skip a few trailing delimiters, because we don't always use
+    #   # this correct tokenizer in later tokens
+    #   while true
+    #     if in->read >= in->write
+    #       break
+    #     curr-byte = in->data[in->read]
+    #     if curr-byte == ':'
+    #       ++in->read
+    #     else if curr-byte == ','
+    #       ++in->read
+    #     else
+    #       break
     #
     # . prologue
     55/push-ebp
@@ -1898,8 +1908,8 @@ $next-mu-token:check-for-close-paren:
       # return
       e9/jump $next-mu-token:done/disp32
     }
-$next-mu-token:regular-word-without-metadata:
     {
+$next-mu-token:regular-word-without-metadata:
       # if (in->read >= in->write) break
       # . ecx = in->read
       8b/-> *(esi+4) 1/r32/ecx
@@ -1918,14 +1928,14 @@ $next-mu-token:regular-word-without-metadata:
       # if (c == ')') break
       3d/compare-eax-and 0x29/imm32/close-paren
       0f 84/jump-if-= break/disp32
-      # ++in->read
-      ff 0/subop/increment *(esi+4)
       # if (c == ':') break
       3d/compare-eax-and 0x3a/imm32/colon
       0f 84/jump-if-= break/disp32
       # if (c == ',') break
       3d/compare-eax-and 0x2c/imm32/comma
       0f 84/jump-if-= break/disp32
+      # ++in->read
+      ff 0/subop/increment *(esi+4)
       #
       e9/jump loop/disp32
     }
@@ -1934,6 +1944,37 @@ $next-mu-token:done:
     8b/-> *(esi+4) 1/r32/ecx
     8d/copy-address *(esi+ecx+0xc) 0/r32/eax
     89/<- *(edi+4) 0/r32/eax
+    {
+$next-mu-token:skip-trailing-delimiters:
+      # if (in->read >= in->write) break
+      # . ecx = in->read
+      8b/-> *(esi+4) 1/r32/ecx
+      # . if (ecx >= in->write) break
+      3b/compare *esi 1/r32/ecx
+      7d/jump-if->= break/disp8
+      # var c/eax: byte = in->data[in->read]
+      31/xor %eax 0/r32/eax
+      8a/copy-byte *(esi+ecx+0xc) 0/r32/AL
+      # if (c == ':') ++in->read and loop
+      {
+        3d/compare-eax-and 0x3a/imm32/colon
+        75/jump-if-!= break/disp8
+        # ++in->read
+        ff 0/subop/increment *(esi+4)
+        #
+        eb/jump $next-mu-token:skip-trailing-delimiters/disp8
+      }
+      # if (c == ',') ++in->read and loop
+      {
+        3d/compare-eax-and 0x2c/imm32/comma
+        75/jump-if-!= break/disp8
+        # ++in->read
+        ff 0/subop/increment *(esi+4)
+        #
+        eb/jump $next-mu-token:skip-trailing-delimiters/disp8
+      }
+      # else break
+    }
 $next-mu-token:end:
     # . restore registers
     5f/pop-to-edi
@@ -1992,6 +2033,9 @@ pos-slice:  # arr: (addr stream (handle array byte)), s: (addr slice) -> index/e
     # return index
     89/<- %eax 1/r32/ecx
 $pos-slice:end:
+    (write-buffered Stderr "=> ")
+    (print-int32-buffered Stderr %eax)
+    (write-buffered Stderr "\n")
     # . restore registers
     5e/pop-to-esi
     5b/pop-to-ebx
@@ -4955,19 +4999,19 @@ type-equal?:  # a : (handle tree type-id), b : (handle tree type-id) => result/e
     39/compare %edx 0/r32/eax  # Var-type
     b8/copy-to-eax 1/imm32/true
     0f 84/jump-if-= $type-equal?:end/disp32
-    # if (a == 0) return false
-    81 7/subop/compare %ecx 0/imm32
+    # if (a < MAX_TYPE_ID) return false
+    81 7/subop/compare %ecx 0x10000/imm32
     b8/copy-to-eax 0/imm32/false
-    0f 84/jump-if-= $type-equal?:end/disp32
+    0f 8c/jump-if-< $type-equal?:end/disp32
     # if (b == 0) return false
-    81 7/subop/compare %edx 0/imm32
+    81 7/subop/compare %edx 0x10000/imm32
     b8/copy-to-eax 0/imm32/false
-    0f 84/jump-if-= $type-equal?:end/disp32
+    0f 8c/jump-if-< $type-equal?:end/disp32
     # if (!type-equal?(a->left, b->left)) return false
     (type-equal? *ecx *edx)  # Tree-left, Tree-left => eax
     3d/compare-eax-and 0/imm32
     0f 84/jump-if-= $type-equal?:end/disp32
-    # return type-equal?(a->right, b->right
+    # return type-equal?(a->right, b->right)
     (type-equal? *(ecx+4) *(edx+4))  # Tree-right, Tree-right => eax
 $type-equal?:end:
     # . restore registers