diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-10-09 21:17:51 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-10-09 21:17:51 -0700 |
commit | 7c6bb4d316a513b276828935162de8429e8e5df0 (patch) | |
tree | 19a98b737f0036bde44bb7ae83b138ab7047168a /apps | |
parent | eb2cccccebe6e396e929a49e08515d3ecea9b0fc (diff) | |
download | mu-7c6bb4d316a513b276828935162de8429e8e5df0.tar.gz |
6977
Snapshot. We've gotten arrow keys navigating, but segfault when getting to the second word in an expanded function call body.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/tile/data.mu | 23 | ||||
-rw-r--r-- | apps/tile/environment.mu | 41 |
2 files changed, 50 insertions, 14 deletions
diff --git a/apps/tile/data.mu b/apps/tile/data.mu index dd30dde0..59918cf1 100644 --- a/apps/tile/data.mu +++ b/apps/tile/data.mu @@ -374,3 +374,26 @@ fn final-element-value list: (addr handle call-path-element) -> result/eax: int var val/eax: (addr int) <- get final, index-in-body result <- copy *val } + +fn push-to-call-path-element list: (addr handle call-path-element), new: int { + var new-element-storage: (handle call-path-element) + var new-element-ah/edi: (addr handle call-path-element) <- address new-element-storage + allocate new-element-ah + var new-element/eax: (addr call-path-element) <- lookup *new-element-ah + # index-in-body + var dest/ecx: (addr int) <- get new-element, index-in-body + var src/edx: int <- copy new + copy-to *dest, src + # next + var dest2/ecx: (addr handle call-path-element) <- get new-element, next + copy-object list, dest2 + # return + copy-object new-element-ah, list +} + +fn drop-from-call-path-element _list: (addr handle call-path-element) { + var list-ah/esi: (addr handle call-path-element) <- copy _list + var list/eax: (addr call-path-element) <- lookup *list-ah + var next/eax: (addr handle call-path-element) <- get list, next + copy-object next, _list +} diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu index 2355ca80..406d1ede 100644 --- a/apps/tile/environment.mu +++ b/apps/tile/environment.mu @@ -101,15 +101,26 @@ $process:body: { cursor-right cursor-word break $process:body } - # otherwise, move to start of next word - var next-word-ah/eax: (addr handle word) <- get cursor-word, next + # otherwise, move to a new word + var next-word-ah/edx: (addr handle word) <- get cursor-word, next var next-word/eax: (addr word) <- lookup *next-word-ah { compare next-word, 0 break-if-= cursor-to-start next-word - var cursor-call-path/eax: (addr handle call-path-element) <- get sandbox, cursor-call-path + # cursor-word now out of date + var cursor-call-path/ecx: (addr handle call-path-element) <- get sandbox, cursor-call-path increment-final-element cursor-call-path + # Is the new cursor word expanded? If so, it's a function call. Add a + # new level to the cursor-call-path for the call's body. + { + var expanded-words/eax: (addr handle call-path) <- get sandbox, expanded-words + var curr-word-is-expanded?/eax: boolean <- find-in-call-path expanded-words, cursor-call-path + compare curr-word-is-expanded?, 0 # false + break-if-= + push-to-call-path-element cursor-call-path, 0 + break $process:body + } } break $process:body } @@ -282,21 +293,21 @@ fn render-sandbox screen: (addr screen), functions: (addr handle function), bind var cursor-word/ebx: (addr word) <- copy _cursor-word # cursor-col var cursor-col: int - var cursor-col-a/eax: (addr int) <- address cursor-col + var cursor-col-a/edx: (addr int) <- address cursor-col # - var dummy/ecx: int <- render-line screen, functions, 0, line, expanded-words, 3, left-col, cursor-word, cursor-col-a # input-row=3 + var curr-path-storage: (handle call-path-element) + var curr-path/esi: (addr handle call-path-element) <- address curr-path-storage + allocate curr-path # leak + var dummy/ecx: int <- render-line screen, functions, 0, line, expanded-words, 3, left-col, curr-path, cursor-word, cursor-col-a # input-row=3 move-cursor screen, 3, cursor-col # input-row } -fn render-line screen: (addr screen), functions: (addr handle function), bindings: (addr table), _line: (addr line), expanded-words: (addr handle call-path), top-row: int, left-col: int, cursor-word: (addr word), cursor-col-a: (addr int) -> right-col/ecx: int { +fn render-line screen: (addr screen), functions: (addr handle function), bindings: (addr table), _line: (addr line), expanded-words: (addr handle call-path), top-row: int, left-col: int, curr-path: (addr handle call-path-element), cursor-word: (addr word), cursor-col-a: (addr int) -> right-col/ecx: int { # curr-word var line/esi: (addr line) <- copy _line var first-word-ah/eax: (addr handle word) <- get line, data var curr-word/eax: (addr word) <- lookup *first-word-ah # - var word-index-storage: (handle call-path-element) - var word-index/ebx: (addr handle call-path-element) <- address word-index-storage - allocate word-index # leak # loop-carried dependency var curr-col/ecx: int <- copy left-col # @@ -310,7 +321,7 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding compare bindings, 0 break-if-!= $render-line:subsidiary # - var display-subsidiary-stack?/eax: boolean <- find-in-call-path expanded-words, word-index + 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 } @@ -356,7 +367,9 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding var callee-body-ah/eax: (addr handle line) <- get callee, body var callee-body/eax: (addr line) <- lookup *callee-body-ah # - render subsidiary stack - curr-col <- render-line screen, functions, callee-bindings, callee-body, 0, top-row, curr-col, cursor-word, cursor-col-a + 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-col-a + drop-from-call-path-element curr-path # move-cursor screen, top-row, curr-col print-code-point screen, 0x21d7 # ⇗ @@ -375,10 +388,10 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding #? reset-formatting screen #? increment top-row # now render main column - curr-col <- render-column screen, functions, bindings, line, curr-word, top-row, curr-col, cursor-word, cursor-col-a + curr-col <- render-column screen, functions, bindings, line, curr-word, top-row, curr-col, curr-path, cursor-word, cursor-col-a var next-word-ah/edx: (addr handle word) <- get curr-word, next curr-word <- lookup *next-word-ah - increment-final-element word-index + increment-final-element curr-path loop } right-col <- copy curr-col @@ -393,7 +406,7 @@ fn render-line screen: (addr screen), functions: (addr handle function), binding # - Return the farthest column written. # - If final-word is same as cursor-word, do some additional computation to set # cursor-col-a. -fn render-column screen: (addr screen), functions: (addr handle function), bindings: (addr table), scratch: (addr line), final-word: (addr word), top-row: int, left-col: int, cursor-word: (addr word), cursor-col-a: (addr int) -> right-col/ecx: int { +fn render-column screen: (addr screen), functions: (addr handle function), bindings: (addr table), scratch: (addr line), final-word: (addr word), top-row: int, left-col: int, cursor-path: (addr handle call-path-element), cursor-word: (addr word), cursor-col-a: (addr int) -> right-col/ecx: int { var max-width/ecx: int <- copy 0 { # indent stack |