about summary refs log tree commit diff stats
path: root/apps/tile
diff options
context:
space:
mode:
Diffstat (limited to 'apps/tile')
-rw-r--r--apps/tile/rpn.mu14
-rw-r--r--apps/tile/table.mu22
2 files changed, 32 insertions, 4 deletions
diff --git a/apps/tile/rpn.mu b/apps/tile/rpn.mu
index 3f331639..b5755ce0 100644
--- a/apps/tile/rpn.mu
+++ b/apps/tile/rpn.mu
@@ -94,12 +94,20 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         var new-byte/eax: byte <- read-byte curr-stream
         compare new-byte, 0x3d  # '='
         break-if-!=
+        var out2/esi: (addr value-stack) <- copy out
+        var top-addr/ecx: (addr int) <- get out2, top
+        compare *top-addr, 0
+        break-if-<=
+        var data-ah/eax: (addr handle array value) <- get out2, data
+        var data/eax: (addr array value) <- lookup *data-ah
+        var top/edx: int <- copy *top-addr
+        top <- decrement
+        var dest-offset/edx: (offset value) <- compute-offset data, top
+        var target-val/edx: (addr value) <- index data, dest-offset
         var key-h: (handle array byte)
         var key/ecx: (addr handle array byte) <- address key-h
         stream-to-string curr-stream, key
-        var foo/eax: (addr array byte) <- lookup *key
-        var val/eax: int <- pop-int-from-value-stack out
-        bind-int-in-table bindings, key, val
+        bind-in-table bindings, key, target-val
         var line/eax: (addr line) <- copy scratch
         var next-line-ah/eax: (addr handle line) <- get line, next
         var next-line/eax: (addr line) <- lookup *next-line-ah
diff --git a/apps/tile/table.mu b/apps/tile/table.mu
index e7dfac40..1ea742c5 100644
--- a/apps/tile/table.mu
+++ b/apps/tile/table.mu
@@ -11,6 +11,16 @@ fn bind-int-in-table _self: (addr table), key: (addr handle array byte), val: in
   var data/esi: (addr array bind) <- copy _data
   var next-empty-slot-index/eax: (offset bind) <- next-empty-slot data, key
   var dest/eax: (addr bind) <- index data, next-empty-slot-index
+  make-int-binding dest, key, val
+}
+
+fn bind-in-table _self: (addr table), key: (addr handle array byte), val: (addr value) {
+  var self/esi: (addr table) <- copy _self
+  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 next-empty-slot-index/eax: (offset bind) <- next-empty-slot data, key
+  var dest/eax: (addr bind) <- index data, next-empty-slot-index
   make-binding dest, key, val
 }
 
@@ -36,7 +46,7 @@ fn next-empty-slot _data: (addr array bind), key: (addr handle array byte) -> re
   }
 }
 
-fn make-binding _self: (addr bind), key: (addr handle array byte), _val: int {
+fn make-int-binding _self: (addr bind), key: (addr handle array byte), _val: int {
   var self/esi: (addr bind) <- copy _self
   var dest/eax: (addr handle array byte) <- get self, key
   copy-object key, dest
@@ -48,6 +58,16 @@ fn make-binding _self: (addr bind), key: (addr handle array byte), _val: int {
   copy-to *dest4, val
 }
 
+fn make-binding _self: (addr bind), key: (addr handle array byte), val: (addr value) {
+  var self/esi: (addr bind) <- copy _self
+  var dest/eax: (addr handle array byte) <- get self, key
+  copy-object key, dest
+  var dest2/eax: (addr handle value) <- get self, value
+  allocate dest2
+  var dest3/eax: (addr value) <- lookup *dest2
+  copy-object val, dest3
+}
+
 fn lookup-binding _self: (addr table), key: (addr array byte), out: (addr handle value) {
   var self/esi: (addr table) <- copy _self
   var data-ah/esi: (addr handle array bind) <- get self, data