about summary refs log tree commit diff stats
path: root/apps/tile/word.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-09-19 18:27:29 -0700
committerKartik Agaram <vc@akkartik.com>2020-09-19 18:27:29 -0700
commita553a5e201b347f4ecc5f0fd9956fb083f941c86 (patch)
treeba6167b3fca05eecb68931d95a54b0cb6704c9af /apps/tile/word.mu
parentabfd0bad29b2a481583207d17f7bd1ebe2ffc2f5 (diff)
downloadmu-a553a5e201b347f4ecc5f0fd9956fb083f941c86.tar.gz
6804 - tile: render all words
Diffstat (limited to 'apps/tile/word.mu')
-rw-r--r--apps/tile/word.mu23
1 files changed, 20 insertions, 3 deletions
diff --git a/apps/tile/word.mu b/apps/tile/word.mu
index c87a2242..1fb214a6 100644
--- a/apps/tile/word.mu
+++ b/apps/tile/word.mu
@@ -25,6 +25,19 @@ fn allocate-word-with _out: (addr handle word), s: (addr array byte) {
   initialize-word-with out-addr, s
 }
 
+# TODO: handle existing next
+# one implication of handles: append must take a handle
+fn append-word _self-ah: (addr handle word) {
+  var self-ah/esi: (addr handle word) <- copy _self-ah
+  var self/eax: (addr word) <- lookup *self-ah
+  var next-ah/eax: (addr handle word) <- get self, next
+  allocate next-ah
+  var next/eax: (addr word) <- lookup *next-ah
+  initialize-word next
+  var prev-ah/eax: (addr handle word) <- get next, prev
+  copy-handle *self-ah, prev-ah
+}
+
 # just for tests for now
 # TODO: handle existing next
 # one implication of handles: append must take a handle
@@ -71,15 +84,19 @@ fn first-word _self: (addr word) -> result/eax: (addr word) {
   result <- copy out
 }
 
-fn final-word _self: (addr word), out: (addr handle word) {
+fn final-word _self: (addr word) -> result/eax: (addr word) {
   var self/esi: (addr word) <- copy _self
+  var out/edi: (addr word) <- copy self
   var next/esi: (addr handle word) <- get self, next
   {
-    copy-object next, out
     var curr/eax: (addr word) <- lookup *next
     compare curr, 0
-    loop-if-!=
+    break-if-=
+    out <- copy curr
+    next <- get curr, next
+    loop
   }
+  result <- copy out
 }
 
 fn add-grapheme-to-word _self: (addr word), c: grapheme {