about summary refs log tree commit diff stats
path: root/apps/tile/main.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-11-09 21:16:09 -0800
committerKartik Agaram <vc@akkartik.com>2020-11-09 21:16:09 -0800
commitc01289dddea2398fe7f4335f5d0babc4a9e789c5 (patch)
tree26aa680c9633a19f1692140f00750aba615b7db5 /apps/tile/main.mu
parent148f2c9b65bcb53379d1c6bf7ec1204735bb2393 (diff)
downloadmu-c01289dddea2398fe7f4335f5d0babc4a9e789c5.tar.gz
7218
This bug was incredibly painful to track down: the one-line fix is to replace
'line' with 'first-line' in the call to 'evaluate' in render-line before
recursing.

Things that made it challenging:
- A high degree of coiling with recursive calls and multiple places of
  evaluation.
- An accidental aliasing in bindings (when rendering the main column in
  render-line) that masked the underlying bug and made things seem to work
  most of the time.
- Too many fucking arguments to render-line, a maze of twisty line objects
  all alike.
Diffstat (limited to 'apps/tile/main.mu')
-rw-r--r--apps/tile/main.mu11
1 files changed, 7 insertions, 4 deletions
diff --git a/apps/tile/main.mu b/apps/tile/main.mu
index 6b18e82e..457c9816 100644
--- a/apps/tile/main.mu
+++ b/apps/tile/main.mu
@@ -71,11 +71,14 @@ fn test {
   initialize-environment-with-fake-screen env, 0x20, 0xa0
   process-all env, "3 3 fake-screen =s"
   process env, 0xc  # ctrl-l
-  process-all env, "s 1 down "
+  process-all env, "s 1 down 1 right"
+  process env, 4  # ctrl-d: start defining function
+  process-all env, "foo"
+  process env, 0xa  # newline: define function
+  process env, 0x435b1b  # right-arrow
+#?   process env, 5  # ctrl-e: end of line
+  process env, 0xa  # newline: expand
   render env
-#?   var fake-screen-ah/eax: (addr handle screen) <- get env, screen
-#?   var fake-screen/eax: (addr screen) <- lookup *fake-screen-ah
-#?   render-screen 0, 1, 1, fake-screen
 }
 
 fn process-all env: (addr environment), cmds: (addr array byte) {
d2e14cdf1c1571a8e80ae30460699d00e82'>0bb09d2e ^
690fa191 ^
0bb09d2e ^







33352536 ^
0bb09d2e ^



33352536 ^
7dac9ade ^
0bb09d2e ^









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59


                                                                        

                                                                              






                                                                                                                                                 



                                                                                                                
                                

                                                                                                                                                                       



                                 


                                                                                                                                                                       
                                
 
                                          



                                                                                                                                                               
                                            







                                     
                                                                                                                                                                  



                        
                           
                                









                                         
# Repeatedly read 32-bit numbers from /dev/random, print them to stdout.
#
# To run:
#   $ ./bootstrap translate init.linux 0*.subx apps/random.subx -o apps/random
#   $ ./bootstrap run apps/random

== code 0x09000000
#   instruction                     effective address                                                   register    displacement    immediate
# . op          subop               mod             rm32          base        index         scale       r32
# . 1-3 bytes   3 bits              2 bits          3 bits        3 bits      3 bits        2 bits      2 bits      0/1/2/4 bytes   0/1/2/4 bytes

Entry:
    # stream/esi = syscall(open, "/dev/null", O_RDONLY, 0)  # we can't use 'fd' because it looks like a hex byte
    bb/copy-to-ebx  Filename/imm32
    b9/copy-to-ecx  0/imm32/rdonly
    ba/copy-to-edx  0x180/imm32/fixed-perms
    e8/call  syscall_open/disp32
    # . stream = eax
    89/copy                         3/mod/direct    6/rm32/esi    .           .             .           0/r32/eax   .               .                 # copy eax to esi

$loop:

    # syscall(read, Stream, N, 4)
    89/copy                         3/mod/direct    3/rm32/ebx    .           .             .           6/r32/esi   .               .                 # copy esi to ebx
    b9/copy-to-ecx  N/imm32
    ba/copy-to-edx  4/imm32/size
    e8/call  syscall_read/disp32

    # write-int32-hex-buffered(Stdout, *N)
    # . . push args
    ff          6/subop/push        0/mod/indirect  5/rm32/.disp32            .             .           .           N/disp32                          # push *N
    68/push  Stdout/imm32
    # . . call
    e8/call  write-int32-hex-buffered/disp32

    # write-buffered(Stdout, Newline)
    # . . push args
    68/push  Newline/imm32
    68/push  Stdout/imm32
    # . . call
    e8/call  write-buffered/disp32
    # . . discard args
    81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp

    eb/jump  $loop/disp8

    # syscall(exit, 0)
    bb/copy-to-ebx  0/imm32
    e8/call  syscall_exit/disp32

== data 0x0a000000

N:
    0/imm32
Filename:
    2f 64 65 76 2f 72 61 6e 64 6f 6d 00
#   /  d  e  v  /  r  a  n  d  o  m  null

# . . vim:nowrap:textwidth=0