about summary refs log tree commit diff stats
path: root/apps/tile
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-11-07 20:12:21 -0800
committerKartik Agaram <vc@akkartik.com>2020-11-07 20:12:21 -0800
commit97b665c9b4bde629fb57eba00e51917b619c892a (patch)
tree78509adb1aa97026bb367091cf3165e04bbdba3c /apps/tile
parent9185512dba34a8c02d4bb8089e27051f3bd74f85 (diff)
downloadmu-97b665c9b4bde629fb57eba00e51917b619c892a.tar.gz
7213 - redo the bugfix of 7210
It turns out deciding when to initialize the table of bindings is quite
a thorny problem in the presence of function calls (since they need their
args bound). In time I should probably support a linked list of tables.
For now I'll just continue to reuse tables, but perform lookups in reverse
order so that the correct binding is always returned.
Diffstat (limited to 'apps/tile')
-rw-r--r--apps/tile/environment.mu1
-rw-r--r--apps/tile/table.mu11
2 files changed, 5 insertions, 7 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index e2eaa13c..17224883 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -1431,7 +1431,6 @@ fn render-column screen: (addr screen), functions: (addr handle function), bindi
     var stack: value-stack
     var stack-addr/edi: (addr value-stack) <- address stack
     initialize-value-stack stack-addr, 0x10  # max-words
-    initialize-table bindings, 0x10
     evaluate functions, bindings, first-line, final-word, stack-addr
     # render stack
     var curr-row/edx: int <- copy top-row
diff --git a/apps/tile/table.mu b/apps/tile/table.mu
index a4a2bae6..fba6918e 100644
--- a/apps/tile/table.mu
+++ b/apps/tile/table.mu
@@ -65,18 +65,18 @@ fn lookup-binding _self: (addr table), key: (addr array byte), out: (addr handle
   var data-ah/esi: (addr handle array bind) <- get self, data
   var _data/eax: (addr array bind) <- lookup *data-ah
   var data/esi: (addr array bind) <- copy _data
-  var len/edx: int <- length data
-  var i/ebx: int <- copy 0
+  var i/edx: int <- length data
   $lookup-binding:loop: {
-    compare i, len
-    break-if->=
+    i <- decrement
+    compare i, 0
+    break-if-<
     {
       var offset/edx: (offset bind) <- compute-offset data, i
       var target-bind/esi: (addr bind) <- index data, offset
       var target2/edx: (addr handle array byte) <- get target-bind, key
       var target3/eax: (addr array byte) <- lookup *target2
       compare target3, 0
-      break-if-= $lookup-binding:loop
+      break-if-=
       var is-match?/eax: boolean <- string-equal? target3, key
       compare is-match?, 0  # false
       break-if-=
@@ -85,7 +85,6 @@ fn lookup-binding _self: (addr table), key: (addr array byte), out: (addr handle
       copy-object target, out
       break $lookup-binding:loop
     }
-    i <- increment
     loop
   }
 }