about summary refs log tree commit diff stats
path: root/apps/tile
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-26 21:50:37 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-26 21:50:37 -0700
commitd5ac55d3ca8b651a63aa677f509833dffa05aab9 (patch)
tree0cfc4c5956e21b9a498b3015062a98d5b3245905 /apps/tile
parent71418907f69cd29ea9a07e7b2f80d51bcec3bba2 (diff)
downloadmu-d5ac55d3ca8b651a63aa677f509833dffa05aab9.tar.gz
7116 - tile: regression in typing in strings
We really need to clean up the Mu compiler's logic around function outputs.
Diffstat (limited to 'apps/tile')
-rw-r--r--apps/tile/main.mu13
-rw-r--r--apps/tile/value-stack.mu88
2 files changed, 46 insertions, 55 deletions
diff --git a/apps/tile/main.mu b/apps/tile/main.mu
index 714695fd..08e6532b 100644
--- a/apps/tile/main.mu
+++ b/apps/tile/main.mu
@@ -77,19 +77,6 @@ fn test {
   initialize-environment-with-fake-screen env, 5, 0xa
   var g/eax: grapheme <- copy 0x22  # '"'
   process env, g
-  g <- copy 0x61  # 'a'
-  process env, g
-  g <- copy 0x22  # '"'
-  process env, g
-  g <- copy 0x20  # space
-  process env, g
-  g <- copy 0x6c  # 'l'
-  process env, g
-  g <- copy 0x65  # 'e'
-  process env, g
-  g <- copy 0x6e  # 'n'
-  print-string 0, "--\n"
-  process env, g
   render env
 }
 
diff --git a/apps/tile/value-stack.mu b/apps/tile/value-stack.mu
index 788a39b7..83b1262a 100644
--- a/apps/tile/value-stack.mu
+++ b/apps/tile/value-stack.mu
@@ -151,49 +151,53 @@ fn value-stack-max-width _self: (addr value-stack) -> result/eax: int {
 }
 
 fn value-width _v: (addr value) -> result/eax: int {
-$value-width:body: {
-  var v/esi: (addr value) <- copy _v
-  var type/eax: (addr int) <- get v, type
-  {
-    compare *type, 0  # int
-    break-if-!=
-    var v-int/edx: (addr int) <- get v, int-data
-    result <- decimal-size *v-int
-    break $value-width:body
-  }
-  {
-    compare *type, 1  # string
-    break-if-!=
-    var s-ah/eax: (addr handle array byte) <- get v, text-data
-    var s/eax: (addr array byte) <- lookup *s-ah
-    compare s, 0
-    break-if-=
-    result <- length s
-    break $value-width:body
-  }
-  {
-    compare *type, 2  # array
-    break-if-!=
-    var a-ah/eax: (addr handle array value) <- get v, array-data
-    var a/eax: (addr array value) <- lookup *a-ah
-    compare a, 0
-    break-if-=
-    result <- array-width a
-    break $value-width:body
-  }
-  {
-    compare *type, 3  # file handle
-    break-if-!=
-    var f-ah/eax: (addr handle buffered-file) <- get v, file-data
-    var f/eax: (addr buffered-file) <- lookup *f-ah
-    compare f, 0
-    break-if-=
-    # TODO
-    result <- copy 4
-    break $value-width:body
-    var w/eax: int <- copy 4
+  var out/edi: int <- copy 0
+  $value-width:body: {
+    var v/esi: (addr value) <- copy _v
+    var type/eax: (addr int) <- get v, type
+    {
+      compare *type, 0  # int
+      break-if-!=
+      var v-int/edx: (addr int) <- get v, int-data
+      var _out/eax: int <- decimal-size *v-int
+      out <- copy _out
+      break $value-width:body
+    }
+    {
+      compare *type, 1  # string
+      break-if-!=
+      var s-ah/eax: (addr handle array byte) <- get v, text-data
+      var s/eax: (addr array byte) <- lookup *s-ah
+      compare s, 0
+      break-if-=
+      var _out/eax: int <- length s
+      out <- copy _out
+      break $value-width:body
+    }
+    {
+      compare *type, 2  # array
+      break-if-!=
+      var a-ah/eax: (addr handle array value) <- get v, array-data
+      var a/eax: (addr array value) <- lookup *a-ah
+      compare a, 0
+      break-if-=
+      var _out/eax: int <- array-width a
+      out <- copy _out
+      break $value-width:body
+    }
+    {
+      compare *type, 3  # file handle
+      break-if-!=
+      var f-ah/eax: (addr handle buffered-file) <- get v, file-data
+      var f/eax: (addr buffered-file) <- lookup *f-ah
+      compare f, 0
+      break-if-=
+      # TODO
+      out <- copy 4
+      break $value-width:body
+    }
   }
-}
+  result <- copy out
 }
 
 # keep sync'd with render-array