about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-10 21:22:00 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-10 21:22:00 -0700
commitae6340f2254d22fcbb05ac9a18b00341886fd341 (patch)
treeb9839289c414e00a016c0e95dc5fd191fcc47554
parent831a133a4b15dfaf81318b848b0cabb7c7c91e98 (diff)
downloadmu-ae6340f2254d22fcbb05ac9a18b00341886fd341.tar.gz
6991 - tile: nested calls now expanding
I just needed to remove an obsolete guardrail in render-line.

Still seeing some bugs with left-arrow when playing around with the full
expansion of `1 2+`.
-rw-r--r--apps/tile/data.mu41
-rw-r--r--apps/tile/environment.mu18
-rw-r--r--apps/tile/main.mu247
3 files changed, 64 insertions, 242 deletions
diff --git a/apps/tile/data.mu b/apps/tile/data.mu
index 726a612a..d864c640 100644
--- a/apps/tile/data.mu
+++ b/apps/tile/data.mu
@@ -461,3 +461,44 @@ fn drop-from-call-path-element _list: (addr handle call-path-element) {
   var next/eax: (addr handle call-path-element) <- get list, next
   copy-object next, _list
 }
+
+fn dump-call-path-element screen: (addr screen), _x-ah: (addr handle call-path-element) {
+$dump-call-path-element:body: {
+  var x-ah/ecx: (addr handle call-path-element) <- copy _x-ah
+  var x/eax: (addr call-path-element) <- lookup *x-ah
+  var src/ecx: (addr int) <- get x, index-in-body
+  print-int32-hex screen, *src
+  var next-ah/ecx: (addr handle call-path-element) <- get x, next
+  var next/eax: (addr call-path-element) <- lookup *next-ah
+  compare next, 0
+  {
+    break-if-=
+    print-string screen, " "
+    dump-call-path-element screen, next-ah
+    break $dump-call-path-element:body
+  }
+  {
+    break-if-!=
+    print-string screen, "\n"
+  }
+}
+}
+
+fn dump-call-paths screen: (addr screen), _x-ah: (addr handle call-path) {
+$dump-call-paths:body: {
+  var x-ah/ecx: (addr handle call-path) <- copy _x-ah
+  var x/eax: (addr call-path) <- lookup *x-ah
+  compare x, 0
+  break-if-=
+  var src/ecx: (addr handle call-path-element) <- get x, data
+  dump-call-path-element screen, src
+  var next-ah/ecx: (addr handle call-path) <- get x, next
+  var next/eax: (addr call-path) <- lookup *next-ah
+  compare next, 0
+  {
+    break-if-=
+    dump-call-paths screen, next-ah
+    break $dump-call-paths:body
+  }
+}
+}
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index e513396e..221118bd 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -397,12 +397,19 @@ $toggle-cursor-word:body: {
   var sandbox/esi: (addr sandbox) <- copy _sandbox
   var expanded-words/edi: (addr handle call-path) <- get sandbox, expanded-words
   var cursor-call-path/ecx: (addr handle call-path-element) <- get sandbox, cursor-call-path
+#?   print-string 0, "cursor call path: "
+#?   dump-call-path-element 0, cursor-call-path
+#?   print-string 0, "expanded words:\n"
+#?   dump-call-paths 0, expanded-words
   var already-expanded?/eax: boolean <- find-in-call-path expanded-words, cursor-call-path
   compare already-expanded?, 0  # false
   {
     break-if-!=
+#?     print-string 0, "expand\n"
     # if not already-expanded, insert
     insert-in-call-path expanded-words cursor-call-path
+#?     print-string 0, "expanded words now:\n"
+#?     dump-call-paths 0, expanded-words
     break $toggle-cursor-word:body
   }
   {
@@ -524,6 +531,8 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
   {
     compare curr-word, 0
     break-if-=
+#?     print-string 0, "-- "
+#?     dump-call-path-element 0, curr-path
 #?     print-word 0, curr-word
 #?     print-string 0, "\n"
 
@@ -533,14 +542,12 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
     # if necessary, first render columns for subsidiary stack
     $render-line:subsidiary: {
       {
-        # can't expand subsidiary stacks for now
-        compare bindings, 0
-        break-if-!= $render-line:subsidiary
-        #
+#?         print-string 0, "check sub\n"
         var display-subsidiary-stack?/eax: boolean <- find-in-call-path expanded-words, curr-path
         compare display-subsidiary-stack?, 0  # false
         break-if-= $render-line:subsidiary
       }
+#?       print-string 0, "render subsidiary stack\n"
       # does function exist?
       var callee/edi: (addr function) <- copy 0
       {
@@ -556,6 +563,7 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
         break-if-= $render-line:subsidiary
       }
       move-cursor screen, top-row, curr-col
+      start-color screen, 8, 7
       print-word screen, curr-word
       {
         var word-len/eax: int <- word-length curr-word
@@ -584,7 +592,7 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding
       var callee-body/eax: (addr line) <- lookup *callee-body-ah
       # - render subsidiary stack
       push-to-call-path-element curr-path, 0  # leak
-      curr-col <- render-line screen, functions, callee-bindings, callee-body, 0, top-row, curr-col, curr-path, cursor-word, cursor-call-path, cursor-col-a
+      curr-col <- render-line screen, functions, callee-bindings, callee-body, expanded-words, top-row, curr-col, curr-path, cursor-word, cursor-call-path, cursor-col-a
       drop-from-call-path-element curr-path
       #
       move-cursor screen, top-row, curr-col
diff --git a/apps/tile/main.mu b/apps/tile/main.mu
index 2f559918..2336b37b 100644
--- a/apps/tile/main.mu
+++ b/apps/tile/main.mu
@@ -81,114 +81,18 @@ fn test {
   process env, g
   g <- copy 0x32  # '2'
   process env, g
-  g <- copy 0x2a  # '*'
+  g <- copy 0x2b  # '+'
   process env, g
   g <- copy 0xa  # <enter>
   process env, g
-  g <- copy 0x20  # space
-  process env, g
-  g <- copy 0x32  # '2'
-  process env, g
-  g <- copy 0x2a  # '*'
-  process env, g
-  g <- copy 0xa  # <enter>
-  process env, g
-  # 12 arrows to return to end of first call
-  g <- copy 0x445b1b  # left-arrow
-  process env, g
-  {
-    print-string-to-real-screen "==\n"
-    var functions/ecx: (addr handle function) <- get env, functions
-    var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
-    var _sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
-    var sandbox/edi: (addr sandbox) <- copy _sandbox
-    var cursor-call-path/edi: (addr handle call-path-element) <- get sandbox, cursor-call-path
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-    cursor-call-path <- get foo, next
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    compare foo, 0
-    break-if-=
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-  }
-  process env, g
-  {
-    print-string-to-real-screen "==\n"
-    var functions/ecx: (addr handle function) <- get env, functions
-    var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
-    var _sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
-    var sandbox/edi: (addr sandbox) <- copy _sandbox
-    var cursor-call-path/edi: (addr handle call-path-element) <- get sandbox, cursor-call-path
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-    cursor-call-path <- get foo, next
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    compare foo, 0
-    break-if-=
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-  }
   g <- copy 0x445b1b  # left-arrow
   process env, g
-  {
-    print-string-to-real-screen "==\n"
-    var functions/ecx: (addr handle function) <- get env, functions
-    var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
-    var _sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
-    var sandbox/edi: (addr sandbox) <- copy _sandbox
-    var cursor-call-path/edi: (addr handle call-path-element) <- get sandbox, cursor-call-path
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-    cursor-call-path <- get foo, next
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    compare foo, 0
-    break-if-=
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-  }
   g <- copy 0x445b1b  # left-arrow
   process env, g
-  {
-    print-string-to-real-screen "==\n"
-    var functions/ecx: (addr handle function) <- get env, functions
-    var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
-    var _sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
-    var sandbox/edi: (addr sandbox) <- copy _sandbox
-    var cursor-call-path/edi: (addr handle call-path-element) <- get sandbox, cursor-call-path
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-    cursor-call-path <- get foo, next
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    compare foo, 0
-    break-if-=
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-  }
   g <- copy 0x445b1b  # left-arrow
   process env, g
   {
-    print-string-to-real-screen "==\n"
+    print-string 0, "== before enter\n"
     var functions/ecx: (addr handle function) <- get env, functions
     var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
     var _sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
@@ -198,7 +102,7 @@ fn test {
     var foo/ecx: (addr call-path-element) <- copy _foo
     var bar/eax: (addr int) <- get foo, index-in-body
     print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
+    print-string 0, "\n"
     cursor-call-path <- get foo, next
     var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
     var foo/ecx: (addr call-path-element) <- copy _foo
@@ -206,127 +110,12 @@ fn test {
     break-if-=
     var bar/eax: (addr int) <- get foo, index-in-body
     print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
+    print-string 0, "\n"
   }
-  g <- copy 0x445b1b  # left-arrow
-  process env, g
-  {
-    print-string-to-real-screen "==\n"
-    var functions/ecx: (addr handle function) <- get env, functions
-    var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
-    var _sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
-    var sandbox/edi: (addr sandbox) <- copy _sandbox
-    var cursor-call-path/edi: (addr handle call-path-element) <- get sandbox, cursor-call-path
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-    cursor-call-path <- get foo, next
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    compare foo, 0
-    break-if-=
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-  }
-  g <- copy 0x445b1b  # left-arrow
-  process env, g
-  {
-    print-string-to-real-screen "==\n"
-    var functions/ecx: (addr handle function) <- get env, functions
-    var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
-    var _sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
-    var sandbox/edi: (addr sandbox) <- copy _sandbox
-    var cursor-call-path/edi: (addr handle call-path-element) <- get sandbox, cursor-call-path
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-    cursor-call-path <- get foo, next
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    compare foo, 0
-    break-if-=
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-  }
-  g <- copy 0x445b1b  # left-arrow
-  process env, g
-  {
-    print-string-to-real-screen "==\n"
-    var functions/ecx: (addr handle function) <- get env, functions
-    var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
-    var _sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
-    var sandbox/edi: (addr sandbox) <- copy _sandbox
-    var cursor-call-path/edi: (addr handle call-path-element) <- get sandbox, cursor-call-path
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-    cursor-call-path <- get foo, next
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    compare foo, 0
-    break-if-=
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-  }
-  g <- copy 0x445b1b  # left-arrow
-  process env, g
-  {
-    print-string-to-real-screen "==\n"
-    var functions/ecx: (addr handle function) <- get env, functions
-    var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
-    var _sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
-    var sandbox/edi: (addr sandbox) <- copy _sandbox
-    var cursor-call-path/edi: (addr handle call-path-element) <- get sandbox, cursor-call-path
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-    cursor-call-path <- get foo, next
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    compare foo, 0
-    break-if-=
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-  }
-  g <- copy 0x445b1b  # left-arrow
-  process env, g
-  {
-    print-string-to-real-screen "==\n"
-    var functions/ecx: (addr handle function) <- get env, functions
-    var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
-    var _sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
-    var sandbox/edi: (addr sandbox) <- copy _sandbox
-    var cursor-call-path/edi: (addr handle call-path-element) <- get sandbox, cursor-call-path
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-    cursor-call-path <- get foo, next
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    compare foo, 0
-    break-if-=
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-  }
-  g <- copy 0x445b1b  # left-arrow
+  g <- copy 0xa  # <enter>
   process env, g
   {
-    print-string-to-real-screen "==\n"
+    print-string 0, "== after enter\n"
     var functions/ecx: (addr handle function) <- get env, functions
     var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
     var _sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
@@ -336,7 +125,7 @@ fn test {
     var foo/ecx: (addr call-path-element) <- copy _foo
     var bar/eax: (addr int) <- get foo, index-in-body
     print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
+    print-string 0, "\n"
     cursor-call-path <- get foo, next
     var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
     var foo/ecx: (addr call-path-element) <- copy _foo
@@ -344,22 +133,7 @@ fn test {
     break-if-=
     var bar/eax: (addr int) <- get foo, index-in-body
     print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
-  }
-  g <- copy 0x445b1b  # left-arrow
-  process env, g
-  {
-    print-string-to-real-screen "==\n"
-    var functions/ecx: (addr handle function) <- get env, functions
-    var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
-    var _sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
-    var sandbox/edi: (addr sandbox) <- copy _sandbox
-    var cursor-call-path/edi: (addr handle call-path-element) <- get sandbox, cursor-call-path
-    var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
-    var foo/ecx: (addr call-path-element) <- copy _foo
-    var bar/eax: (addr int) <- get foo, index-in-body
-    print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
+    print-string 0, "\n"
     cursor-call-path <- get foo, next
     var _foo/eax: (addr call-path-element) <- lookup *cursor-call-path
     var foo/ecx: (addr call-path-element) <- copy _foo
@@ -367,10 +141,9 @@ fn test {
     break-if-=
     var bar/eax: (addr int) <- get foo, index-in-body
     print-int32-hex 0, *bar
-    print-string-to-real-screen "\n"
+    print-string 0, "\n"
   }
-  g <- copy 0x445b1b  # left-arrow
-  process env, g
+  print-string 0, "== render\n"
   render env
 }
 
ref='#n70'>70 71 72 73 74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194