about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-27 00:29:47 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-27 00:43:14 -0700
commit332998546db0c08f57a7bd5138db038012ca9837 (patch)
tree51ae0975eb5f681320b973f09076a582c60fb24e /apps
parent307a75530fc63939a2356bf99a04a8107d2ae800 (diff)
downloadmu-332998546db0c08f57a7bd5138db038012ca9837.tar.gz
7124 - tiles: better 'lines' primitive
Diffstat (limited to 'apps')
-rw-r--r--apps/tile/rpn.mu31
-rw-r--r--apps/tile/value-stack.mu2
2 files changed, 19 insertions, 14 deletions
diff --git a/apps/tile/rpn.mu b/apps/tile/rpn.mu
index 2529e5ca..5446bdb8 100644
--- a/apps/tile/rpn.mu
+++ b/apps/tile/rpn.mu
@@ -229,27 +229,30 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         # read target-val as a filename and save the handle in target-val
         var file-ah/eax: (addr handle buffered-file) <- get target-val, file-data
         var file/eax: (addr buffered-file) <- lookup *file-ah
-        var h: (handle array (handle array byte))
-        var ah/ecx: (addr handle array (handle array byte)) <- address h
+        var s: (stream byte 0x100)
+        var s-addr/ecx: (addr stream byte) <- address s
+        slurp file, s-addr
+        var tmp-ah/eax: (addr handle array byte) <- get target-val, text-data
+        stream-to-array s-addr, tmp-ah
+        var tmp/eax: (addr array byte) <- lookup *tmp-ah
 #?         enable-screen-type-mode
-#?         clear-screen 0
-        read-lines file, ah
-#?         {
-#?           var x/eax: (addr array (handle array byte)) <- lookup h
-#?           var len/eax: int <- length x
-#?           var foo/eax: int <- copy len
-#?           print-string 0, "aa: "
-#?           print-int32-hex 0, foo
-#?           print-string 0, "\n"
-#?         }
+#?         print-string 0, tmp
+        var h: (handle array (handle array byte))
+        {
+          var ah/edx: (addr handle array (handle array byte)) <- address h
+          split-string tmp, 0xa, ah
+        }
         var target/eax: (addr handle array value) <- get target-val, array-data
         save-lines h, target
         # save result into target-val
         var type-addr/eax: (addr int) <- get target-val, type
         copy-to *type-addr, 2  # array
         var target-file-ah/eax: (addr handle buffered-file) <- get target-val, file-data
-        var empty: (handle buffered-file)
-        copy-handle empty, target-file-ah
+        var empty-file: (handle buffered-file)
+        copy-handle empty-file, target-file-ah
+        var target-text-ah/eax: (addr handle array byte) <- get target-val, text-data
+        var empty-text: (handle array byte)
+        copy-handle empty-text, target-text-ah
         break $evaluate:process-word
       }
       # if curr-stream defines a binding, save top of stack to bindings
diff --git a/apps/tile/value-stack.mu b/apps/tile/value-stack.mu
index 99e013bb..b954bf25 100644
--- a/apps/tile/value-stack.mu
+++ b/apps/tile/value-stack.mu
@@ -177,6 +177,8 @@ fn value-width _v: (addr value) -> result/eax: int {
         break-if-<=
         out <- copy 0xd
       }
+      # we won't add 2 for surrounding quotes since we don't surround arrays
+      # in spaces like other value types
       break $value-width:body
     }
     {