about summary refs log tree commit diff stats
path: root/apps/tile
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-11-10 19:32:54 -0800
committerKartik Agaram <vc@akkartik.com>2020-11-10 19:32:54 -0800
commit3ae62cfd79a5435a2c230da5a8dfd8a1a8fa4abd (patch)
tree83684e8f7a31216f32d91e7812cc9155ce61cdc5 /apps/tile
parent021c2975aa45e653125c3ba8bcd477d7cb7f43cb (diff)
downloadmu-3ae62cfd79a5435a2c230da5a8dfd8a1a8fa4abd.tar.gz
7222
Ok, I found a failing manual test for files as well.

Here are the two steelman tests, one for screens and one for files:

1.
  5 5 fake-screen =s

  s 1 down 1 right

  ctrl-d foo

  expand

final state:

  s       foo                                            foo
               s       1       down    1       right   ⇗
   ┌─────┐                                                ┌─────┐
                ┌─────┐      1  ┌─────┐      1  ┌─────┐    │
                        ┌─────┐  │      ┌─────┐  │         ─
                                         │       │
                                         │       │
                                                 ─
   └─────┘                                                └─────┘
                └─────┘         └─────┘         └─────┘
                        └─────┘         └─────┘

2.

  "x" open =f

  f read f read

  ctrl-d read2

  expand

final state:

  f      read2                                read2
                f      read   f      read   ⇗
    FILE                                       ❝def❞
                  FILE  ❝abc❞   FILE  ❝❞
                               ❝def❞  ❝ghi❞

In both cases there are 3 levels of issues:

- getting a single-line expression to work
- getting a single-line expression to work when operating on a binding
  defined in a previous line
- getting an expanded function call to work

The third is where the rub is right now. And what both examples above share
is that the function performs 2 mutations to the screen/file.

So we need a deep copy after all. And it's not very clear how to copy a
file descriptor including the seek location. Linux's dup() syscall creates
an alias to the file descriptor. And opening /proc seems awfully Linux-specific:

https://stackoverflow.com/questions/54727231/duplicating-file-descriptor-and-seeking-through-both-of-them-independently/54727424#54727424
Diffstat (limited to 'apps/tile')
-rw-r--r--apps/tile/environment.mu25
-rw-r--r--apps/tile/rpn.mu13
-rw-r--r--apps/tile/value.mu5
3 files changed, 0 insertions, 43 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index 0be875e9..a268291c 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -1294,12 +1294,6 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
 #?     print-string 0, "-- word "
 #?     print-word 0, curr-word
 #?     print-string 0, "\n"
-#?     print-string 0, "-- word in final line: "
-#?     {
-#?       var foo/eax: int <- copy curr-word
-#?       print-int32-hex 0, foo
-#?     }
-#?     print-string 0, "\n"
     # if necessary, first render columns for subsidiary stack
     $render-line:subsidiary: {
       {
@@ -1330,8 +1324,6 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
         increment top-row
       }
       # obtain stack at call site
-#?       print-string 0, "sub 0 bindings: "
-#?       dump-table bindings
       var stack-storage: value-stack
       var stack/edx: (addr value-stack) <- address stack-storage
       initialize-value-stack stack, 0x10
@@ -1340,15 +1332,11 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
         var prev-word/eax: (addr word) <- lookup *prev-word-ah
         compare prev-word, 0
         break-if-=
-#?         print-string 0, "sub 1 bindings: "
-#?         dump-table bindings
         var bindings2-storage: table
         var bindings2/ebx: (addr table) <- address bindings2-storage
         shallow-copy-table-values bindings, bindings2
         evaluate functions, bindings2, first-line, prev-word, stack
       }
-#?       print-string 0, "sub 2 bindings: "
-#?       dump-table bindings
       # construct new bindings
       var callee-bindings-storage: table
       var callee-bindings/esi: (addr table) <- address callee-bindings-storage
@@ -1380,23 +1368,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"
-#?     print-string 0, "main 0 bindings: "
-#?     dump-table bindings
     var bindings2-storage: table
     var bindings2/ebx: (addr table) <- address bindings2-storage
     shallow-copy-table-values bindings, bindings2
-#?     print-string 0, "main 1 bindings: "
-#?     dump-table bindings
-#?     print-string 0, "main 1 bindings2: "
-#?     dump-table bindings2
-#?     print-string 0, "word: "
-#?     print-word 0, curr-word
-#?     print-string 0, "\n"
     curr-col <- render-column screen, functions, bindings2, first-line, line, curr-word, top-row, curr-col
-#?     print-string 0, "main 2 bindings: "
-#?     dump-table bindings
-#?     print-string 0, "main 2 bindings2: "
-#?     dump-table bindings2
     # cache cursor column if necessary
     $render-line:cache-cursor-column: {
 #?       print-string 0, "cache cursor? "
diff --git a/apps/tile/rpn.mu b/apps/tile/rpn.mu
index ab722f09..cc8e0163 100644
--- a/apps/tile/rpn.mu
+++ b/apps/tile/rpn.mu
@@ -279,7 +279,6 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         allocate screen-ah
         var screen/eax: (addr screen) <- lookup screen-h
         initialize-screen screen, nrows, ncols
-#?         render-screen 0, 5, 5, screen
         # push screen to stack
         var data-ah/eax: (addr handle array value) <- get out2, data
         var data/eax: (addr array value) <- lookup *data-ah
@@ -410,7 +409,6 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         var top-addr/ebx: (addr int) <- get out2, top
         compare *top-addr, 0
         break-if-<=
-#?         print-string 0, "DOWN\n"
         # pop args
         var _d/eax: int <- pop-int-from-value-stack out2
         var d/ecx: int <- copy _d
@@ -430,8 +428,6 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         var target-ah/eax: (addr handle screen) <- get target-val, screen-data
         var _target/eax: (addr screen) <- lookup *target-ah
         var target/edi: (addr screen) <- copy _target
-#?         print-string 0, "before:\n"
-#?         render-screen 0, 5, 5, target
         var bound-a/ebx: (addr int) <- get target, num-rows
         var bound/ebx: int <- copy *bound-a
         var r/edx: (addr int) <- get target, cursor-row
@@ -448,8 +444,6 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
           d <- decrement
           loop
         }
-#?         print-string 0, "after:\n"
-#?         render-screen 0, 5, 5, target
         break $evaluate:process-word
       }
       {
@@ -613,9 +607,6 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         top <- decrement
         var dest-offset/edx: (offset value) <- compute-offset data, top
         var target-val/edx: (addr value) <- index data, dest-offset
-#?         var tmp-ah/eax: (addr handle screen) <- get target-val, screen-data
-#?         var tmp/eax: (addr screen) <- lookup *tmp-ah
-#?         render-screen 0, 5, 5, tmp
         # create binding from curr-stream to target-val
         var key-h: (handle array byte)
         var key/ecx: (addr handle array byte) <- address key-h
@@ -649,11 +640,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         var val/eax: (addr value) <- lookup *val-ah
         compare val, 0
         break-if-=
-#?         print-string-to-real-screen "AA\n"
         push-value-stack out, val
-#?         var tmp-ah/eax: (addr handle screen) <- get val, screen-data
-#?         var tmp/eax: (addr screen) <- lookup *tmp-ah
-#?         render-screen 0, 5, 5, tmp
         break $evaluate:process-word
       }
       ### if the word starts with a quote and ends with a quote, turn it into a string
diff --git a/apps/tile/value.mu b/apps/tile/value.mu
index cc046a04..ad526901 100644
--- a/apps/tile/value.mu
+++ b/apps/tile/value.mu
@@ -5,9 +5,6 @@ fn render-value-at screen: (addr screen), row: int, col: int, _val: (addr value)
   move-cursor screen, row, col
   var val/esi: (addr value) <- copy _val
   var val-type/ecx: (addr int) <- get val, type
-#?   print-string-to-real-screen "value type: "
-#?   print-int32-decimal-to-real-screen *val-type
-#?   print-string-to-real-screen "\n"
   # per-type rendering logic goes here
   compare *val-type, 1  # string
   {
@@ -148,7 +145,6 @@ fn render-screen screen: (addr screen), row: int, col: int, _target-screen: (add
     break-if->
     increment row  # mutate arg
     move-cursor screen, row, col
-#?     print-string screen, "\n"
     print-string screen, " "
     var c/edi: int <- copy 1
     {
@@ -163,7 +159,6 @@ fn render-screen screen: (addr screen), row: int, col: int, _target-screen: (add
     loop
   }
   increment row  # mutate arg
-#?   print-string screen, "\n"
   move-cursor screen, row, col
   start-color screen, 0xf2, 7
   print-lower-border screen, *ncols-a