about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-11-07 20:52:12 -0800
committerKartik Agaram <vc@akkartik.com>2020-11-07 21:13:10 -0800
commit4cf8be04e97d94385a8bfe21f2c09d6e53110e28 (patch)
tree175025babf7e23db703121e41971e44d34700c22 /apps
parent8fdf344ea9f63d4d733c28067c3732681de65fa5 (diff)
downloadmu-4cf8be04e97d94385a8bfe21f2c09d6e53110e28.tar.gz
7215
Attempt #3: always create a copy of the bindings before each column/evaluate.
The details are fuzzy in my head, but it seemed worth trying. I figured
I'd either see the old duplication behavior or everything will work. Instead
I'm seeing new problems.

  commit 7208:
    5 5 fake-screen =s
    s 1 down 1 right

    expected:
      |
      -

    observed:
      |
      |
      -

  commit 7210-7212:
    5 5 fake-screen =s
    s 1 down 1 right
    [define foo]
    s foo
    [expand foo]

    observed: no bindings available when rendering foo expanded

  commit 7213:
    5 5 fake-screen =s
    s 1 down 1 right
    [define foo]
    s foo
    [expand foo]

    expected within foo:
      |
      -

    observed within foo:
      |
      |
      -

  commit 7215:
    5 5 fake-screen =s
    s 1 down 1 right
    [define foo]
    s foo
    [expand foo]

    observed: no bindings available when rendering foo expanded
Diffstat (limited to 'apps')
-rw-r--r--apps/tile/environment.mu6
-rw-r--r--apps/tile/table.mu27
2 files changed, 31 insertions, 2 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index e2eaa13c..597cad95 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -1363,7 +1363,10 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
 #?     print-string 0, "rendering column from "
 #?     print-int32-decimal 0, curr-col
 #?     print-string 0, "\n"
-    curr-col <- render-column screen, functions, bindings, first-line, line, curr-word, top-row, curr-col
+    var bindings2-storage: table
+    var bindings2/ebx: (addr table) <- address bindings2-storage
+    shallow-copy-table-values bindings, bindings2
+    curr-col <- render-column screen, functions, bindings2, first-line, line, curr-word, top-row, curr-col
     # cache cursor column if necessary
     $render-line:cache-cursor-column: {
 #?       print-string 0, "cache cursor? "
@@ -1431,7 +1434,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..23924d16 100644
--- a/apps/tile/table.mu
+++ b/apps/tile/table.mu
@@ -4,6 +4,33 @@ fn initialize-table _self: (addr table), n: int {
   populate data-ah, n
 }
 
+fn shallow-copy-table-values _src: (addr table), dest: (addr table) {
+  var src/eax: (addr table) <- copy _src
+  var src-data-ah/eax: (addr handle array bind) <- get src, data
+  var _src-data/eax: (addr array bind) <- lookup *src-data-ah
+  var src-data/esi: (addr array bind) <- copy _src-data
+  var n/ecx: int <- length src-data
+  initialize-table dest, n
+  var i/eax: int <- copy 0
+  {
+    compare i, n
+    break-if->=
+    {
+      var offset/edx: (offset bind) <- compute-offset src-data, i
+      var src-bind/ecx: (addr bind) <- index src-data, offset
+      var key-ah/ebx: (addr handle array byte) <- get src-bind, key
+      var key/eax: (addr array byte) <- lookup *key-ah
+      compare key, 0
+      break-if-=
+      var val-ah/eax: (addr handle value) <- get src-bind, value
+      var val/eax: (addr value) <- lookup *val-ah
+      bind-in-table dest, key-ah, val
+    }
+    i <- increment
+    loop
+  }
+}
+
 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