Browse Source

keep 'grapheme-stack'

We want to at least document intent there.
main
Kartik Agaram 8 months ago
parent
commit
53d69dd1c5
  1. 230
      513grapheme-stack.mu
  2. 180
      514gap-buffer.mu
  3. 230
      html/513grapheme-stack.mu.html
  4. 180
      html/514gap-buffer.mu.html
  5. 102
      html/linux/tile/gap-buffer.mu.html
  6. 50
      html/linux/tile/grapheme-stack.mu.html
  7. 8
      html/linux/tile/word.mu.html
  8. 42
      html/signatures.mu.html
  9. 102
      linux/tile/gap-buffer.mu
  10. 50
      linux/tile/grapheme-stack.mu
  11. 8
      linux/tile/word.mu
  12. 42
      signatures.mu

230
513grapheme-stack.mu

@ -1,26 +1,26 @@
# code-point-utf8 stacks are the smallest unit of editable text
type code-point-utf8-stack {
type grapheme-stack {
data: (handle array code-point-utf8)
top: int
}
fn initialize-code-point-utf8-stack _self: (addr code-point-utf8-stack), n: int {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn initialize-grapheme-stack _self: (addr grapheme-stack), n: int {
var self/esi: (addr grapheme-stack) <- copy _self
var d/edi: (addr handle array code-point-utf8) <- get self, data
populate d, n
var top/eax: (addr int) <- get self, top
copy-to *top, 0
}
fn clear-code-point-utf8-stack _self: (addr code-point-utf8-stack) {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn clear-grapheme-stack _self: (addr grapheme-stack) {
var self/esi: (addr grapheme-stack) <- copy _self
var top/eax: (addr int) <- get self, top
copy-to *top, 0
}
fn code-point-utf8-stack-empty? _self: (addr code-point-utf8-stack) -> _/eax: boolean {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn grapheme-stack-empty? _self: (addr grapheme-stack) -> _/eax: boolean {
var self/esi: (addr grapheme-stack) <- copy _self
var top/eax: (addr int) <- get self, top
compare *top, 0
{
@ -30,14 +30,14 @@ fn code-point-utf8-stack-empty? _self: (addr code-point-utf8-stack) -> _/eax: bo
return 0/false
}
fn code-point-utf8-stack-length _self: (addr code-point-utf8-stack) -> _/eax: int {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn grapheme-stack-length _self: (addr grapheme-stack) -> _/eax: int {
var self/esi: (addr grapheme-stack) <- copy _self
var top/eax: (addr int) <- get self, top
return *top
}
fn push-code-point-utf8-stack _self: (addr code-point-utf8-stack), _val: code-point-utf8 {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn push-grapheme-stack _self: (addr grapheme-stack), _val: code-point-utf8 {
var self/esi: (addr grapheme-stack) <- copy _self
var top-addr/ecx: (addr int) <- get self, top
var data-ah/edx: (addr handle array code-point-utf8) <- get self, data
var data/eax: (addr array code-point-utf8) <- lookup *data-ah
@ -48,8 +48,8 @@ fn push-code-point-utf8-stack _self: (addr code-point-utf8-stack), _val: code-po
add-to *top-addr, 1
}
fn pop-code-point-utf8-stack _self: (addr code-point-utf8-stack) -> _/eax: code-point-utf8 {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn pop-grapheme-stack _self: (addr grapheme-stack) -> _/eax: code-point-utf8 {
var self/esi: (addr grapheme-stack) <- copy _self
var top-addr/ecx: (addr int) <- get self, top
{
compare *top-addr, 0
@ -64,8 +64,8 @@ fn pop-code-point-utf8-stack _self: (addr code-point-utf8-stack) -> _/eax: code-
return *result-addr
}
fn copy-code-point-utf8-stack _src: (addr code-point-utf8-stack), dest: (addr code-point-utf8-stack) {
var src/esi: (addr code-point-utf8-stack) <- copy _src
fn copy-grapheme-stack _src: (addr grapheme-stack), dest: (addr grapheme-stack) {
var src/esi: (addr grapheme-stack) <- copy _src
var data-ah/edi: (addr handle array code-point-utf8) <- get src, data
var _data/eax: (addr array code-point-utf8) <- lookup *data-ah
var data/edi: (addr array code-point-utf8) <- copy _data
@ -75,7 +75,7 @@ fn copy-code-point-utf8-stack _src: (addr code-point-utf8-stack), dest: (addr co
compare i, *top-addr
break-if->=
var g/edx: (addr code-point-utf8) <- index data, i
push-code-point-utf8-stack dest, *g
push-grapheme-stack dest, *g
i <- increment
loop
}
@ -84,8 +84,8 @@ fn copy-code-point-utf8-stack _src: (addr code-point-utf8-stack), dest: (addr co
# dump stack to screen from bottom to top
# hardcoded colors:
# matching paren
fn render-stack-from-bottom-wrapping-right-then-down screen: (addr screen), _self: (addr code-point-utf8-stack), xmin: int, ymin: int, xmax: int, ymax: int, _x: int, _y: int, highlight-matching-open-paren?: boolean, open-paren-depth: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn render-stack-from-bottom-wrapping-right-then-down screen: (addr screen), _self: (addr grapheme-stack), xmin: int, ymin: int, xmax: int, ymax: int, _x: int, _y: int, highlight-matching-open-paren?: boolean, open-paren-depth: int, color: int, background-color: int -> _/eax: int, _/ecx: int {
var self/esi: (addr grapheme-stack) <- copy _self
var matching-open-paren-index/edx: int <- get-matching-open-paren-index self, highlight-matching-open-paren?, open-paren-depth
var data-ah/edi: (addr handle array code-point-utf8) <- get self, data
var _data/eax: (addr array code-point-utf8) <- lookup *data-ah
@ -123,7 +123,7 @@ fn render-stack-from-bottom-wrapping-right-then-down screen: (addr screen), _sel
}
# helper for small words
fn render-stack-from-bottom screen: (addr screen), self: (addr code-point-utf8-stack), x: int, y: int, highlight-matching-open-paren?: boolean, open-paren-depth: int -> _/eax: int {
fn render-stack-from-bottom screen: (addr screen), self: (addr grapheme-stack), x: int, y: int, highlight-matching-open-paren?: boolean, open-paren-depth: int -> _/eax: int {
var _width/eax: int <- copy 0
var _height/ecx: int <- copy 0
_width, _height <- screen-size screen
@ -140,8 +140,8 @@ fn render-stack-from-bottom screen: (addr screen), self: (addr code-point-utf8-s
# hard-coded colors:
# matching paren
# cursor
fn render-stack-from-top-wrapping-right-then-down screen: (addr screen), _self: (addr code-point-utf8-stack), xmin: int, ymin: int, xmax: int, ymax: int, _x: int, _y: int, render-cursor?: boolean, color: int, background-color: int -> _/eax: int, _/ecx: int {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn render-stack-from-top-wrapping-right-then-down screen: (addr screen), _self: (addr grapheme-stack), xmin: int, ymin: int, xmax: int, ymax: int, _x: int, _y: int, render-cursor?: boolean, color: int, background-color: int -> _/eax: int, _/ecx: int {
var self/esi: (addr grapheme-stack) <- copy _self
var matching-close-paren-index/edx: int <- get-matching-close-paren-index self, render-cursor?
var data-ah/eax: (addr handle array code-point-utf8) <- get self, data
var _data/eax: (addr array code-point-utf8) <- lookup *data-ah
@ -196,7 +196,7 @@ fn render-stack-from-top-wrapping-right-then-down screen: (addr screen), _self:
}
# helper for small words
fn render-stack-from-top screen: (addr screen), self: (addr code-point-utf8-stack), x: int, y: int, render-cursor?: boolean -> _/eax: int {
fn render-stack-from-top screen: (addr screen), self: (addr grapheme-stack), x: int, y: int, render-cursor?: boolean -> _/eax: int {
var _width/eax: int <- copy 0
var _height/ecx: int <- copy 0
_width, _height <- screen-size screen
@ -208,190 +208,190 @@ fn render-stack-from-top screen: (addr screen), self: (addr code-point-utf8-stac
return x2 # y2? yolo
}
fn test-render-code-point-utf8-stack {
fn test-render-grapheme-stack {
# setup: gs = "abc"
var gs-storage: code-point-utf8-stack
var gs/edi: (addr code-point-utf8-stack) <- address gs-storage
initialize-code-point-utf8-stack gs, 5
var gs-storage: grapheme-stack
var gs/edi: (addr grapheme-stack) <- address gs-storage
initialize-grapheme-stack gs, 5
var g/eax: code-point-utf8 <- copy 0x61/a
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x62/b
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x63/c
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
# setup: screen
var screen-storage: screen
var screen/esi: (addr screen) <- address screen-storage
initialize-screen screen, 5, 4, 0/no-pixel-graphics
#
var x/eax: int <- render-stack-from-bottom screen, gs, 0/x, 0/y, 0/no-highlight-matching-open-paren, 0/open-paren-depth
check-screen-row screen, 0/y, "abc ", "F - test-render-code-point-utf8-stack from bottom"
check-ints-equal x, 3, "F - test-render-code-point-utf8-stack from bottom: result"
check-background-color-in-screen-row screen, 3/bg=reverse, 0/y, " ", "F - test-render-code-point-utf8-stack from bottom: bg"
check-screen-row screen, 0/y, "abc ", "F - test-render-grapheme-stack from bottom"
check-ints-equal x, 3, "F - test-render-grapheme-stack from bottom: result"
check-background-color-in-screen-row screen, 3/bg=reverse, 0/y, " ", "F - test-render-grapheme-stack from bottom: bg"
#
var x/eax: int <- render-stack-from-top screen, gs, 0/x, 1/y, 0/cursor=false
check-screen-row screen, 1/y, "cba ", "F - test-render-code-point-utf8-stack from top without cursor"
check-ints-equal x, 3, "F - test-render-code-point-utf8-stack from top without cursor: result"
check-background-color-in-screen-row screen, 3/bg=reverse, 1/y, " ", "F - test-render-code-point-utf8-stack from top without cursor: bg"
check-screen-row screen, 1/y, "cba ", "F - test-render-grapheme-stack from top without cursor"
check-ints-equal x, 3, "F - test-render-grapheme-stack from top without cursor: result"
check-background-color-in-screen-row screen, 3/bg=reverse, 1/y, " ", "F - test-render-grapheme-stack from top without cursor: bg"
#
var x/eax: int <- render-stack-from-top screen, gs, 0/x, 2/y, 1/cursor=true
check-screen-row screen, 2/y, "cba ", "F - test-render-code-point-utf8-stack from top with cursor"
check-ints-equal x, 3, "F - test-render-code-point-utf8-stack from top with cursor: result"
check-background-color-in-screen-row screen, 3/bg=reverse, 2/y, "| ", "F - test-render-code-point-utf8-stack from top with cursor: bg"
check-screen-row screen, 2/y, "cba ", "F - test-render-grapheme-stack from top with cursor"
check-ints-equal x, 3, "F - test-render-grapheme-stack from top with cursor: result"
check-background-color-in-screen-row screen, 3/bg=reverse, 2/y, "| ", "F - test-render-grapheme-stack from top with cursor: bg"
}
fn test-render-code-point-utf8-stack-while-highlighting-matching-close-paren {
fn test-render-grapheme-stack-while-highlighting-matching-close-paren {
# setup: gs = "(b)"
var gs-storage: code-point-utf8-stack
var gs/edi: (addr code-point-utf8-stack) <- address gs-storage
initialize-code-point-utf8-stack gs, 5
var gs-storage: grapheme-stack
var gs/edi: (addr grapheme-stack) <- address gs-storage
initialize-grapheme-stack gs, 5
var g/eax: code-point-utf8 <- copy 0x29/close-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x62/b
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x28/open-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
# setup: screen
var screen-storage: screen
var screen/esi: (addr screen) <- address screen-storage
initialize-screen screen, 5, 4, 0/no-pixel-graphics
#
var x/eax: int <- render-stack-from-top screen, gs, 0/x, 2/y, 1/cursor=true
check-screen-row screen, 2/y, "(b) ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-close-paren"
check-background-color-in-screen-row screen, 3/bg=reverse, 2/y, "| ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-close-paren: cursor"
check-screen-row-in-color screen, 0xf/fg=white, 2/y, " ) ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-close-paren: matching paren"
check-screen-row screen, 2/y, "(b) ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren"
check-background-color-in-screen-row screen, 3/bg=reverse, 2/y, "| ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren: cursor"
check-screen-row-in-color screen, 0xf/fg=white, 2/y, " ) ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren: matching paren"
}
fn test-render-code-point-utf8-stack-while-highlighting-matching-close-paren-2 {
fn test-render-grapheme-stack-while-highlighting-matching-close-paren-2 {
# setup: gs = "(a (b)) c"
var gs-storage: code-point-utf8-stack
var gs/edi: (addr code-point-utf8-stack) <- address gs-storage
initialize-code-point-utf8-stack gs, 0x10
var gs-storage: grapheme-stack
var gs/edi: (addr grapheme-stack) <- address gs-storage
initialize-grapheme-stack gs, 0x10
var g/eax: code-point-utf8 <- copy 0x63/c
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x20/space
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x29/close-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x29/close-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x62/b
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x28/open-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x20/space
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x61/a
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x28/open-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
# setup: screen
var screen-storage: screen
var screen/esi: (addr screen) <- address screen-storage
initialize-screen screen, 5, 4, 0/no-pixel-graphics
#
var x/eax: int <- render-stack-from-top screen, gs, 0/x, 2/y, 1/cursor=true
check-screen-row screen, 2/y, "(a (b)) c ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-close-paren-2"
check-background-color-in-screen-row screen, 3/bg=reverse, 2/y, "| ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-close-paren-2: cursor"
check-screen-row-in-color screen, 0xf/fg=white, 2/y, " ) ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-close-paren-2: matching paren"
check-screen-row screen, 2/y, "(a (b)) c ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren-2"
check-background-color-in-screen-row screen, 3/bg=reverse, 2/y, "| ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren-2: cursor"
check-screen-row-in-color screen, 0xf/fg=white, 2/y, " ) ", "F - test-render-grapheme-stack-while-highlighting-matching-close-paren-2: matching paren"
}
fn test-render-code-point-utf8-stack-while-highlighting-matching-open-paren-with-close-paren-at-end {
fn test-render-grapheme-stack-while-highlighting-matching-open-paren-with-close-paren-at-end {
# setup: gs = "(b)"
var gs-storage: code-point-utf8-stack
var gs/edi: (addr code-point-utf8-stack) <- address gs-storage
initialize-code-point-utf8-stack gs, 5
var gs-storage: grapheme-stack
var gs/edi: (addr grapheme-stack) <- address gs-storage
initialize-grapheme-stack gs, 5
var g/eax: code-point-utf8 <- copy 0x28/open-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x62/b
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x29/close-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
# setup: screen
var screen-storage: screen
var screen/esi: (addr screen) <- address screen-storage
initialize-screen screen, 5, 4, 0/no-pixel-graphics
#
var x/eax: int <- render-stack-from-bottom screen, gs, 0/x, 2/y, 1/highlight-matching-open-paren, 1/open-paren-depth
check-screen-row screen, 2/y, "(b) ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-open-paren-with-close-paren-at-end"
check-screen-row-in-color screen, 0xf/fg=white, 2/y, "( ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-open-paren-with-close-paren-at-end: matching paren"
check-screen-row screen, 2/y, "(b) ", "F - test-render-grapheme-stack-while-highlighting-matching-open-paren-with-close-paren-at-end"
check-screen-row-in-color screen, 0xf/fg=white, 2/y, "( ", "F - test-render-grapheme-stack-while-highlighting-matching-open-paren-with-close-paren-at-end: matching paren"
}
fn test-render-code-point-utf8-stack-while-highlighting-matching-open-paren-with-close-paren-at-end-2 {
fn test-render-grapheme-stack-while-highlighting-matching-open-paren-with-close-paren-at-end-2 {
# setup: gs = "a((b))"
var gs-storage: code-point-utf8-stack
var gs/edi: (addr code-point-utf8-stack) <- address gs-storage
initialize-code-point-utf8-stack gs, 0x10
var gs-storage: grapheme-stack
var gs/edi: (addr grapheme-stack) <- address gs-storage
initialize-grapheme-stack gs, 0x10
var g/eax: code-point-utf8 <- copy 0x61/a
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x28/open-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x28/open-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x62/b
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x29/close-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x29/close-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
# setup: screen
var screen-storage: screen
var screen/esi: (addr screen) <- address screen-storage
initialize-screen screen, 5, 4, 0/no-pixel-graphics
#
var x/eax: int <- render-stack-from-bottom screen, gs, 0/x, 2/y, 1/highlight-matching-open-paren, 1/open-paren-depth
check-screen-row screen, 2/y, "a((b)) ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-open-paren-with-close-paren-at-end-2"
check-screen-row-in-color screen, 0xf/fg=white, 2/y, " ( ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-open-paren-with-close-paren-at-end-2: matching paren"
check-screen-row screen, 2/y, "a((b)) ", "F - test-render-grapheme-stack-while-highlighting-matching-open-paren-with-close-paren-at-end-2"
check-screen-row-in-color screen, 0xf/fg=white, 2/y, " ( ", "F - test-render-grapheme-stack-while-highlighting-matching-open-paren-with-close-paren-at-end-2: matching paren"
}
fn test-render-code-point-utf8-stack-while-highlighting-matching-open-paren {
fn test-render-grapheme-stack-while-highlighting-matching-open-paren {
# setup: gs = "(b"
var gs-storage: code-point-utf8-stack
var gs/edi: (addr code-point-utf8-stack) <- address gs-storage
initialize-code-point-utf8-stack gs, 5
var gs-storage: grapheme-stack
var gs/edi: (addr grapheme-stack) <- address gs-storage
initialize-grapheme-stack gs, 5
var g/eax: code-point-utf8 <- copy 0x28/open-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x62/b
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
# setup: screen
var screen-storage: screen
var screen/esi: (addr screen) <- address screen-storage
initialize-screen screen, 5, 4, 0/no-pixel-graphics
#
var x/eax: int <- render-stack-from-bottom screen, gs, 0/x, 2/y, 1/highlight-matching-open-paren, 0/open-paren-depth
check-screen-row screen, 2/y, "(b ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-open-paren"
check-screen-row-in-color screen, 0xf/fg=white, 2/y, "( ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-open-paren: matching paren"
check-screen-row screen, 2/y, "(b ", "F - test-render-grapheme-stack-while-highlighting-matching-open-paren"
check-screen-row-in-color screen, 0xf/fg=white, 2/y, "( ", "F - test-render-grapheme-stack-while-highlighting-matching-open-paren: matching paren"
}
fn test-render-code-point-utf8-stack-while-highlighting-matching-open-paren-2 {
fn test-render-grapheme-stack-while-highlighting-matching-open-paren-2 {
# setup: gs = "a((b)"
var gs-storage: code-point-utf8-stack
var gs/edi: (addr code-point-utf8-stack) <- address gs-storage
initialize-code-point-utf8-stack gs, 0x10
var gs-storage: grapheme-stack
var gs/edi: (addr grapheme-stack) <- address gs-storage
initialize-grapheme-stack gs, 0x10
var g/eax: code-point-utf8 <- copy 0x61/a
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x28/open-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x28/open-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x62/b
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
g <- copy 0x29/close-paren
push-code-point-utf8-stack gs, g
push-grapheme-stack gs, g
# setup: screen
var screen-storage: screen
var screen/esi: (addr screen) <- address screen-storage
initialize-screen screen, 5, 4, 0/no-pixel-graphics
#
var x/eax: int <- render-stack-from-bottom screen, gs, 0/x, 2/y, 1/highlight-matching-open-paren, 0/open-paren-depth
check-screen-row screen, 2/y, "a((b) ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-open-paren-2"
check-screen-row-in-color screen, 0xf/fg=white, 2/y, " ( ", "F - test-render-code-point-utf8-stack-while-highlighting-matching-open-paren-2: matching paren"
check-screen-row screen, 2/y, "a((b) ", "F - test-render-grapheme-stack-while-highlighting-matching-open-paren-2"
check-screen-row-in-color screen, 0xf/fg=white, 2/y, " ( ", "F - test-render-grapheme-stack-while-highlighting-matching-open-paren-2: matching paren"
}
# return the index of the matching close-paren of the code-point-utf8 at cursor (top of stack)
# or top index if there's no matching close-paren
fn get-matching-close-paren-index _self: (addr code-point-utf8-stack), render-cursor?: boolean -> _/edx: int {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn get-matching-close-paren-index _self: (addr grapheme-stack), render-cursor?: boolean -> _/edx: int {
var self/esi: (addr grapheme-stack) <- copy _self
var top-addr/edx: (addr int) <- get self, top
# if not rendering cursor, return
compare render-cursor?, 0/false
@ -446,8 +446,8 @@ fn get-matching-close-paren-index _self: (addr code-point-utf8-stack), render-cu
# return the index of the first open-paren at the given depth
# or top index if there's no matching close-paren
fn get-matching-open-paren-index _self: (addr code-point-utf8-stack), control: boolean, depth: int -> _/edx: int {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn get-matching-open-paren-index _self: (addr grapheme-stack), control: boolean, depth: int -> _/edx: int {
var self/esi: (addr grapheme-stack) <- copy _self
var top-addr/edx: (addr int) <- get self, top
# if not rendering cursor, return
compare control, 0/false
@ -494,8 +494,8 @@ fn get-matching-open-paren-index _self: (addr code-point-utf8-stack), control: b
# compare from bottom
# beware: modifies 'stream', which must be disposed of after a false result
fn prefix-match? _self: (addr code-point-utf8-stack), s: (addr stream byte) -> _/eax: boolean {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn prefix-match? _self: (addr grapheme-stack), s: (addr stream byte) -> _/eax: boolean {
var self/esi: (addr grapheme-stack) <- copy _self
var data-ah/edi: (addr handle array code-point-utf8) <- get self, data
var _data/eax: (addr array code-point-utf8) <- lookup *data-ah
var data/edi: (addr array code-point-utf8) <- copy _data
@ -522,8 +522,8 @@ fn prefix-match? _self: (addr code-point-utf8-stack), s: (addr stream byte) -> _
# compare from bottom
# beware: modifies 'stream', which must be disposed of after a false result
fn suffix-match? _self: (addr code-point-utf8-stack), s: (addr stream byte) -> _/eax: boolean {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn suffix-match? _self: (addr grapheme-stack), s: (addr stream byte) -> _/eax: boolean {
var self/esi: (addr grapheme-stack) <- copy _self
var data-ah/edi: (addr handle array code-point-utf8) <- get self, data
var _data/eax: (addr array code-point-utf8) <- lookup *data-ah
var data/edi: (addr array code-point-utf8) <- copy _data
@ -549,15 +549,15 @@ fn suffix-match? _self: (addr code-point-utf8-stack), s: (addr stream byte) -> _
return 1 # true
}
fn code-point-utf8-stack-is-decimal-integer? _self: (addr code-point-utf8-stack) -> _/eax: boolean {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn grapheme-stack-is-decimal-integer? _self: (addr grapheme-stack) -> _/eax: boolean {
var self/esi: (addr grapheme-stack) <- copy _self
var data-ah/eax: (addr handle array code-point-utf8) <- get self, data
var _data/eax: (addr array code-point-utf8) <- lookup *data-ah
var data/edx: (addr array code-point-utf8) <- copy _data
var top-addr/ecx: (addr int) <- get self, top
var i/ebx: int <- copy 0
var result/eax: boolean <- copy 1/true
$code-point-utf8-stack-is-integer?:loop: {
$grapheme-stack-is-integer?:loop: {
compare i, *top-addr
break-if->=
var g/edx: (addr code-point-utf8) <- index data, i

180
514gap-buffer.mu

@ -1,8 +1,8 @@
# primitive for editing text
type gap-buffer {
left: code-point-utf8-stack
right: code-point-utf8-stack
left: grapheme-stack
right: grapheme-stack
# some fields for scanning incrementally through a gap-buffer
left-read-index: int
right-read-index: int
@ -10,39 +10,39 @@ type gap-buffer {
fn initialize-gap-buffer _self: (addr gap-buffer), capacity: int {
var self/esi: (addr gap-buffer) <- copy _self
var left/eax: (addr code-point-utf8-stack) <- get self, left
initialize-code-point-utf8-stack left, capacity
var right/eax: (addr code-point-utf8-stack) <- get self, right
initialize-code-point-utf8-stack right, capacity
var left/eax: (addr grapheme-stack) <- get self, left
initialize-grapheme-stack left, capacity
var right/eax: (addr grapheme-stack) <- get self, right
initialize-grapheme-stack right, capacity
}
fn clear-gap-buffer _self: (addr gap-buffer) {
var self/esi: (addr gap-buffer) <- copy _self
var left/eax: (addr code-point-utf8-stack) <- get self, left
clear-code-point-utf8-stack left
var right/eax: (addr code-point-utf8-stack) <- get self, right
clear-code-point-utf8-stack right
var left/eax: (addr grapheme-stack) <- get self, left
clear-grapheme-stack left
var right/eax: (addr grapheme-stack) <- get self, right
clear-grapheme-stack right
}
fn gap-buffer-empty? _self: (addr gap-buffer) -> _/eax: boolean {
var self/esi: (addr gap-buffer) <- copy _self
# if !empty?(left) return false
{
var left/eax: (addr code-point-utf8-stack) <- get self, left
var result/eax: boolean <- code-point-utf8-stack-empty? left
var left/eax: (addr grapheme-stack) <- get self, left
var result/eax: boolean <- grapheme-stack-empty? left
compare result, 0/false
break-if-!=
return 0/false
}
# return empty?(right)
var left/eax: (addr code-point-utf8-stack) <- get self, left
var result/eax: boolean <- code-point-utf8-stack-empty? left
var left/eax: (addr grapheme-stack) <- get self, left
var result/eax: boolean <- grapheme-stack-empty? left
return result
}
fn gap-buffer-capacity _gap: (addr gap-buffer) -> _/edx: int {
var gap/esi: (addr gap-buffer) <- copy _gap
var left/eax: (addr code-point-utf8-stack) <- get gap, left
var left/eax: (addr grapheme-stack) <- get gap, left
var left-data-ah/eax: (addr handle array code-point-utf8) <- get left, data
var left-data/eax: (addr array code-point-utf8) <- lookup *left-data-ah
var result/eax: int <- length left-data
@ -86,15 +86,15 @@ fn emit-gap-buffer self: (addr gap-buffer), out: (addr stream byte) {
fn append-gap-buffer _self: (addr gap-buffer), out: (addr stream byte) {
var self/esi: (addr gap-buffer) <- copy _self
var left/eax: (addr code-point-utf8-stack) <- get self, left
var left/eax: (addr grapheme-stack) <- get self, left
emit-stack-from-bottom left, out
var right/eax: (addr code-point-utf8-stack) <- get self, right
var right/eax: (addr grapheme-stack) <- get self, right
emit-stack-from-top right, out
}
# dump stack from bottom to top
fn emit-stack-from-bottom _self: (addr code-point-utf8-stack), out: (addr stream byte) {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn emit-stack-from-bottom _self: (addr grapheme-stack), out: (addr stream byte) {
var self/esi: (addr grapheme-stack) <- copy _self
var data-ah/edi: (addr handle array code-point-utf8) <- get self, data
var _data/eax: (addr array code-point-utf8) <- lookup *data-ah
var data/edi: (addr array code-point-utf8) <- copy _data
@ -111,8 +111,8 @@ fn emit-stack-from-bottom _self: (addr code-point-utf8-stack), out: (addr stream
}
# dump stack from top to bottom
fn emit-stack-from-top _self: (addr code-point-utf8-stack), out: (addr stream byte) {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn emit-stack-from-top _self: (addr grapheme-stack), out: (addr stream byte) {
var self/esi: (addr grapheme-stack) <- copy _self
var data-ah/edi: (addr handle array code-point-utf8) <- get self, data
var _data/eax: (addr array code-point-utf8) <- lookup *data-ah
var data/edi: (addr array code-point-utf8) <- copy _data
@ -139,10 +139,10 @@ fn word-at-gap _self: (addr gap-buffer), out: (addr stream byte) {
break-if-!=
return
}
var left/ecx: (addr code-point-utf8-stack) <- get self, left
var left/ecx: (addr grapheme-stack) <- get self, left
var left-index/eax: int <- top-most-word left
emit-stack-from-index left, left-index, out
var right/ecx: (addr code-point-utf8-stack) <- get self, right
var right/ecx: (addr grapheme-stack) <- get self, right
var right-index/eax: int <- top-most-word right
emit-stack-to-index right, right-index, out
}
@ -243,7 +243,7 @@ fn test-word-at-gap-multiple-words-with-gap-at-final-non-word {
fn code-point-utf8-at-gap _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
# send top of right most of the time
var self/esi: (addr gap-buffer) <- copy _self
var right/edi: (addr code-point-utf8-stack) <- get self, right
var right/edi: (addr grapheme-stack) <- get self, right
var data-ah/eax: (addr handle array code-point-utf8) <- get right, data
var data/eax: (addr array code-point-utf8) <- lookup *data-ah
var top-addr/ecx: (addr int) <- get right, top
@ -256,7 +256,7 @@ fn code-point-utf8-at-gap _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
return *result
}
# send top of left only if right is empty
var left/edi: (addr code-point-utf8-stack) <- get self, left
var left/edi: (addr grapheme-stack) <- get self, left
var data-ah/eax: (addr handle array code-point-utf8) <- get left, data
var data/eax: (addr array code-point-utf8) <- lookup *data-ah
var top-addr/ecx: (addr int) <- get left, top
@ -272,8 +272,8 @@ fn code-point-utf8-at-gap _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
return 0
}
fn top-most-word _self: (addr code-point-utf8-stack) -> _/eax: int {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn top-most-word _self: (addr grapheme-stack) -> _/eax: int {
var self/esi: (addr grapheme-stack) <- copy _self
var data-ah/edi: (addr handle array code-point-utf8) <- get self, data
var _data/eax: (addr array code-point-utf8) <- lookup *data-ah
var data/edi: (addr array code-point-utf8) <- copy _data
@ -294,8 +294,8 @@ fn top-most-word _self: (addr code-point-utf8-stack) -> _/eax: int {
return i
}
fn emit-stack-from-index _self: (addr code-point-utf8-stack), start: int, out: (addr stream byte) {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn emit-stack-from-index _self: (addr grapheme-stack), start: int, out: (addr stream byte) {
var self/esi: (addr grapheme-stack) <- copy _self
var data-ah/edi: (addr handle array code-point-utf8) <- get self, data
var _data/eax: (addr array code-point-utf8) <- lookup *data-ah
var data/edi: (addr array code-point-utf8) <- copy _data
@ -311,8 +311,8 @@ fn emit-stack-from-index _self: (addr code-point-utf8-stack), start: int, out: (
}
}
fn emit-stack-to-index _self: (addr code-point-utf8-stack), end: int, out: (addr stream byte) {
var self/esi: (addr code-point-utf8-stack) <- copy _self
fn emit-stack-to-index _self: (addr grapheme-stack), end: int, out: (addr stream byte) {
var self/esi: (addr grapheme-stack) <- copy _self
var data-ah/edi: (addr handle array code-point-utf8) <- get self, data
var _data/eax: (addr array code-point-utf8) <- lookup *data-ah
var data/edi: (addr array code-point-utf8) <- copy _data
@ -384,14 +384,14 @@ fn is-ascii-word-code-point-utf8? g: code-point-utf8 -> _/eax: boolean {
# cursor is a single other color.
fn render-gap-buffer-wrapping-right-then-down screen: (addr screen), _gap: (addr gap-buffer), xmin: int, ymin: int, xmax: int, ymax: int, render-cursor?: boolean, color: int, background-color: int -> _/eax: int, _/ecx: int {
var gap/esi: (addr gap-buffer) <- copy _gap
var left/edx: (addr code-point-utf8-stack) <- get gap, left
var left/edx: (addr grapheme-stack) <- get gap, left
var highlight-matching-open-paren?/ebx: boolean <- copy 0/false
var matching-open-paren-depth/edi: int <- copy 0
highlight-matching-open-paren?, matching-open-paren-depth <- highlight-matching-open-paren? gap, render-cursor?
var x2/eax: int <- copy 0
var y2/ecx: int <- copy 0
x2, y2 <- render-stack-from-bottom-wrapping-right-then-down screen, left, xmin, ymin, xmax, ymax, xmin, ymin, highlight-matching-open-paren?, matching-open-paren-depth, color, background-color
var right/edx: (addr code-point-utf8-stack) <- get gap, right
var right/edx: (addr grapheme-stack) <- get gap, right
x2, y2 <- render-stack-from-top-wrapping-right-then-down screen, right, xmin, ymin, xmax, ymax, x2, y2, render-cursor?, color, background-color
# decide whether we still need to print a cursor
var fg/edi: int <- copy color
@ -400,7 +400,7 @@ fn render-gap-buffer-wrapping-right-then-down screen: (addr screen), _gap: (addr
{
break-if-=
# if the right side is empty, code-point-utf8 stack didn't print the cursor
var empty?/eax: boolean <- code-point-utf8-stack-empty? right
var empty?/eax: boolean <- grapheme-stack-empty? right
compare empty?, 0/false
break-if-=
# swap foreground and background
@ -427,10 +427,10 @@ fn render-gap-buffer screen: (addr screen), gap: (addr gap-buffer), x: int, y: i
fn gap-buffer-length _gap: (addr gap-buffer) -> _/eax: int {
var gap/esi: (addr gap-buffer) <- copy _gap
var left/eax: (addr code-point-utf8-stack) <- get gap, left
var left/eax: (addr grapheme-stack) <- get gap, left
var tmp/eax: (addr int) <- get left, top
var left-length/ecx: int <- copy *tmp
var right/esi: (addr code-point-utf8-stack) <- get gap, right
var right/esi: (addr grapheme-stack) <- get gap, right
tmp <- get right, top
var result/eax: int <- copy *tmp
result <- add left-length
@ -439,8 +439,8 @@ fn gap-buffer-length _gap: (addr gap-buffer) -> _/eax: int {
fn add-code-point-utf8-at-gap _self: (addr gap-buffer), g: code-point-utf8 {
var self/esi: (addr gap-buffer) <- copy _self
var left/eax: (addr code-point-utf8-stack) <- get self, left
push-code-point-utf8-stack left, g
var left/eax: (addr grapheme-stack) <- get self, left
push-grapheme-stack left, g
}
fn add-code-point-at-gap self: (addr gap-buffer), c: code-point {
@ -466,28 +466,28 @@ fn gap-to-end self: (addr gap-buffer) {
fn gap-at-start? _self: (addr gap-buffer) -> _/eax: boolean {
var self/esi: (addr gap-buffer) <- copy _self
var left/eax: (addr code-point-utf8-stack) <- get self, left
var result/eax: boolean <- code-point-utf8-stack-empty? left
var left/eax: (addr grapheme-stack) <- get self, left
var result/eax: boolean <- grapheme-stack-empty? left
return result
}
fn gap-at-end? _self: (addr gap-buffer) -> _/eax: boolean {
var self/esi: (addr gap-buffer) <- copy _self
var right/eax: (addr code-point-utf8-stack) <- get self, right
var result/eax: boolean <- code-point-utf8-stack-empty? right
var right/eax: (addr grapheme-stack) <- get self, right
var result/eax: boolean <- grapheme-stack-empty? right
return result
}
fn gap-right _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
var self/esi: (addr gap-buffer) <- copy _self
var g/eax: code-point-utf8 <- copy 0
var right/ecx: (addr code-point-utf8-stack) <- get self, right
g <- pop-code-point-utf8-stack right
var right/ecx: (addr grapheme-stack) <- get self, right
g <- pop-grapheme-stack right
compare g, -1
{
break-if-=
var left/ecx: (addr code-point-utf8-stack) <- get self, left
push-code-point-utf8-stack left, g
var left/ecx: (addr grapheme-stack) <- get self, left
push-grapheme-stack left, g
}
return g
}
@ -496,21 +496,21 @@ fn gap-left _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
var self/esi: (addr gap-buffer) <- copy _self
var g/eax: code-point-utf8 <- copy 0
{
var left/ecx: (addr code-point-utf8-stack) <- get self, left
g <- pop-code-point-utf8-stack left
var left/ecx: (addr grapheme-stack) <- get self, left
g <- pop-grapheme-stack left
}
compare g, -1
{
break-if-=
var right/ecx: (addr code-point-utf8-stack) <- get self, right
push-code-point-utf8-stack right, g
var right/ecx: (addr grapheme-stack) <- get self, right
push-grapheme-stack right, g
}
return g
}
fn index-of-gap _self: (addr gap-buffer) -> _/eax: int {
var self/eax: (addr gap-buffer) <- copy _self
var left/eax: (addr code-point-utf8-stack) <- get self, left
var left/eax: (addr grapheme-stack) <- get self, left
var top-addr/eax: (addr int) <- get left, top
var result/eax: int <- copy *top-addr
return result
@ -519,7 +519,7 @@ fn index-of-gap _self: (addr gap-buffer) -> _/eax: int {
fn first-code-point-utf8-in-gap-buffer _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
var self/esi: (addr gap-buffer) <- copy _self
# try to read from left
var left/eax: (addr code-point-utf8-stack) <- get self, left
var left/eax: (addr grapheme-stack) <- get self, left
var top-addr/ecx: (addr int) <- get left, top
compare *top-addr, 0
{
@ -530,7 +530,7 @@ fn first-code-point-utf8-in-gap-buffer _self: (addr gap-buffer) -> _/eax: code-p
return *result-addr
}
# try to read from right
var right/eax: (addr code-point-utf8-stack) <- get self, right
var right/eax: (addr grapheme-stack) <- get self, right
top-addr <- get right, top
compare *top-addr, 0
{
@ -549,13 +549,13 @@ fn first-code-point-utf8-in-gap-buffer _self: (addr gap-buffer) -> _/eax: code-p
fn code-point-utf8-before-cursor-in-gap-buffer _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
var self/esi: (addr gap-buffer) <- copy _self
# try to read from left
var left/ecx: (addr code-point-utf8-stack) <- get self, left
var left/ecx: (addr grapheme-stack) <- get self, left
var top-addr/edx: (addr int) <- get left, top
compare *top-addr, 0
{
break-if-<=
var result/eax: code-point-utf8 <- pop-code-point-utf8-stack left
push-code-point-utf8-stack left, result
var result/eax: code-point-utf8 <- pop-grapheme-stack left
push-grapheme-stack left, result
return result
}
# give up
@ -564,14 +564,14 @@ fn code-point-utf8-before-cursor-in-gap-buffer _self: (addr gap-buffer) -> _/eax
fn delete-before-gap _self: (addr gap-buffer) {
var self/eax: (addr gap-buffer) <- copy _self
var left/eax: (addr code-point-utf8-stack) <- get self, left
var dummy/eax: code-point-utf8 <- pop-code-point-utf8-stack left
var left/eax: (addr grapheme-stack) <- get self, left
var dummy/eax: code-point-utf8 <- pop-grapheme-stack left
}
fn pop-after-gap _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
var self/eax: (addr gap-buffer) <- copy _self
var right/eax: (addr code-point-utf8-stack) <- get self, right
var result/eax: code-point-utf8 <- pop-code-point-utf8-stack right
var right/eax: (addr grapheme-stack) <- get self, right
var result/eax: code-point-utf8 <- pop-grapheme-stack right
return result
}
@ -584,7 +584,7 @@ fn gap-buffer-equal? _self: (addr gap-buffer), s: (addr array byte) -> _/eax: bo
var expected-stream/ecx: (addr stream byte) <- address stream-storage
write expected-stream, s
# compare left
var left/edx: (addr code-point-utf8-stack) <- get self, left
var left/edx: (addr grapheme-stack) <- get self, left
var result/eax: boolean <- prefix-match? left, expected-stream
compare result, 0/false
{
@ -592,7 +592,7 @@ fn gap-buffer-equal? _self: (addr gap-buffer), s: (addr array byte) -> _/eax: bo
return result
}
# compare right
var right/edx: (addr code-point-utf8-stack) <- get self, right
var right/edx: (addr grapheme-stack) <- get self, right
result <- suffix-match? right, expected-stream
compare result, 0/false
{
@ -691,7 +691,7 @@ fn gap-index _self: (addr gap-buffer), _n: int -> _/eax: code-point-utf8 {
var self/esi: (addr gap-buffer) <- copy _self
var n/ebx: int <- copy _n
# if n < left->length, index into left
var left/edi: (addr code-point-utf8-stack) <- get self, left
var left/edi: (addr grapheme-stack) <- get self, left
var left-len-a/edx: (addr int) <- get left, top
compare n, *left-len-a
{
@ -704,7 +704,7 @@ fn gap-index _self: (addr gap-buffer), _n: int -> _/eax: code-point-utf8 {
# shrink n
n <- subtract *left-len-a
# if n < right->length, index into right
var right/edi: (addr code-point-utf8-stack) <- get self, right
var right/edi: (addr grapheme-stack) <- get self, right
var right-len-a/edx: (addr int) <- get right, top
compare n, *right-len-a
{
@ -788,25 +788,25 @@ fn copy-gap-buffer _src-ah: (addr handle gap-buffer), _dest-ah: (addr handle gap
var dest-ah/eax: (addr handle gap-buffer) <- copy _dest-ah
var _dest-a/eax: (addr gap-buffer) <- lookup *dest-ah
var dest-a/edi: (addr gap-buffer) <- copy _dest-a
# copy left code-point-utf8-stack
var src/ecx: (addr code-point-utf8-stack) <- get src-a, left
var dest/edx: (addr code-point-utf8-stack) <- get dest-a, left
copy-code-point-utf8-stack src, dest
# copy right code-point-utf8-stack
# copy left grapheme-stack
var src/ecx: (addr grapheme-stack) <- get src-a, left
var dest/edx: (addr grapheme-stack) <- get dest-a, left
copy-grapheme-stack src, dest
# copy right grapheme-stack
src <- get src-a, right
dest <- get dest-a, right
copy-code-point-utf8-stack src, dest
copy-grapheme-stack src, dest
}
fn gap-buffer-is-decimal-integer? _self: (addr gap-buffer) -> _/eax: boolean {
var self/esi: (addr gap-buffer) <- copy _self
var curr/ecx: (addr code-point-utf8-stack) <- get self, left
var result/eax: boolean <- code-point-utf8-stack-is-decimal-integer? curr
var curr/ecx: (addr grapheme-stack) <- get self, left
var result/eax: boolean <- grapheme-stack-is-decimal-integer? curr
{
compare result, 0/false
break-if-=
curr <- get self, right
result <- code-point-utf8-stack-is-decimal-integer? curr
result <- grapheme-stack-is-decimal-integer? curr
}
return result
}
@ -947,7 +947,7 @@ fn highlight-matching-open-paren? _gap: (addr gap-buffer), render-cursor?: boole
return 0/false, 0
}
var gap/esi: (addr gap-buffer) <- copy _gap
var stack/edi: (addr code-point-utf8-stack) <- get gap, right
var stack/edi: (addr grapheme-stack) <- get gap, right
var top-addr/eax: (addr int) <- get stack, top
var top-index/ecx: int <- copy *top-addr
compare top-index, 0
@ -1022,8 +1022,8 @@ fn rewind-gap-buffer _self: (addr gap-buffer) {
fn gap-buffer-scan-done? _self: (addr gap-buffer) -> _/eax: boolean {
var self/esi: (addr gap-buffer) <- copy _self
# more in left?
var left/eax: (addr code-point-utf8-stack) <- get self, left
var left-size/eax: int <- code-point-utf8-stack-length left
var left/eax: (addr grapheme-stack) <- get self, left
var left-size/eax: int <- grapheme-stack-length left
var left-read-index/ecx: (addr int) <- get self, left-read-index
compare *left-read-index, left-size
{
@ -1031,8 +1031,8 @@ fn gap-buffer-scan-done? _self: (addr gap-buffer) -> _/eax: boolean {
return 0/false
}
# more in right?
var right/eax: (addr code-point-utf8-stack) <- get self, right
var right-size/eax: int <- code-point-utf8-stack-length right
var right/eax: (addr grapheme-stack) <- get self, right
var right-size/eax: int <- grapheme-stack-length right
var right-read-index/ecx: (addr int) <- get self, right-read-index
compare *right-read-index, right-size
{
@ -1046,8 +1046,8 @@ fn gap-buffer-scan-done? _self: (addr gap-buffer) -> _/eax: boolean {
fn peek-from-gap-buffer _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
var self/esi: (addr gap-buffer) <- copy _self
# more in left?
var left/ecx: (addr code-point-utf8-stack) <- get self, left
var left-size/eax: int <- code-point-utf8-stack-length left
var left/ecx: (addr grapheme-stack) <- get self, left
var left-size/eax: int <- grapheme-stack-length left
var left-read-index-a/edx: (addr int) <- get self, left-read-index
compare *left-read-index-a, left-size
{
@ -1059,8 +1059,8 @@ fn peek-from-gap-buffer _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
return *result
}
# more in right?
var right/ecx: (addr code-point-utf8-stack) <- get self, right
var _right-size/eax: int <- code-point-utf8-stack-length right
var right/ecx: (addr grapheme-stack) <- get self, right
var _right-size/eax: int <- grapheme-stack-length right
var right-size/ebx: int <- copy _right-size
var right-read-index-a/edx: (addr int) <- get self, right-read-index
compare *right-read-index-a, right-size
@ -1082,8 +1082,8 @@ fn peek-from-gap-buffer _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
fn read-from-gap-buffer _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
var self/esi: (addr gap-buffer) <- copy _self
# more in left?
var left/ecx: (addr code-point-utf8-stack) <- get self, left
var left-size/eax: int <- code-point-utf8-stack-length left
var left/ecx: (addr grapheme-stack) <- get self, left
var left-size/eax: int <- grapheme-stack-length left
var left-read-index-a/edx: (addr int) <- get self, left-read-index
compare *left-read-index-a, left-size
{
@ -1096,8 +1096,8 @@ fn read-from-gap-buffer _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
return *result
}
# more in right?
var right/ecx: (addr code-point-utf8-stack) <- get self, right
var _right-size/eax: int <- code-point-utf8-stack-length right
var right/ecx: (addr grapheme-stack) <- get self, right
var _right-size/eax: int <- grapheme-stack-length right
var right-size/ebx: int <- copy _right-size
var right-read-index-a/edx: (addr int) <- get self, right-read-index
compare *right-read-index-a, right-size
@ -1120,8 +1120,8 @@ fn read-from-gap-buffer _self: (addr gap-buffer) -> _/eax: code-point-utf8 {
fn put-back-from-gap-buffer _self: (addr gap-buffer) {
var self/esi: (addr gap-buffer) <- copy _self
# more in right?
var right/eax: (addr code-point-utf8-stack) <- get self, right
var right-size/eax: int <- code-point-utf8-stack-length right
var right/eax: (addr grapheme-stack) <- get self, right
var right-size/eax: int <- grapheme-stack-length right
var right-read-index-a/eax: (addr int) <- get self, right-read-index
compare *right-read-index-a, 0
{
@ -1130,8 +1130,8 @@ fn put-back-from-gap-buffer _self: (addr gap-buffer) {
return
}
# more in left?
var left/eax: (addr code-point-utf8-stack) <- get self, left
var left-size/eax: int <- code-point-utf8-stack-length left
var left/eax: (addr grapheme-stack) <- get self, left
var left-size/eax: int <- grapheme-stack-length left
var left-read-index-a/eax: (addr int) <- get self, left-read-index
decrement *left-read-index-a
}

230
html/513grapheme-stack.mu.html generated

@ -64,27 +64,27 @@ if ('onhashchange' in window) {
<pre id='vimCodeElement'>
<span id="L1" class="LineNr"> 1 </span><span class="muComment"># code-point-utf8 stacks are the smallest unit of editable text</span>
<span id="L2" class="LineNr"> 2 </span>
<span id="L3" class="LineNr"> 3 </span><span class="PreProc">type</span> <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack</a> <span class="Delimiter">{</span>
<span id="L3" class="LineNr"> 3 </span><span class="PreProc">type</span> <a href='513grapheme-stack.mu.html#L3'>grapheme-stack</a> <span class="Delimiter">{</span>
<span id="L4" class="LineNr"> 4 </span> data: (handle array code-point-utf8)
<span id="L5" class="LineNr"> 5 </span> top: int
<span id="L6" class="LineNr"> 6 </span><span class="Delimiter">}</span>
<span id="L7" class="LineNr"> 7 </span>
<span id="L8" class="LineNr"> 8 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='513grapheme-stack.mu.html#L8'>initialize-code-point-utf8-stack</a></span> _self: (addr <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack</a>), n: int <span class="Delimiter">{</span>
<span id="L9" class="LineNr"> 9 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack</a>) <span class="Special">&lt;-</span> copy _self
<span id="L8" class="LineNr"> 8 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='513grapheme-stack.mu.html#L8'>initialize-grapheme-stack</a></span> _self: (addr <a href='513grapheme-stack.mu.html#L3'>grapheme-stack</a>), n: int <span class="Delimiter">{</span>
<span id="L9" class="LineNr"> 9 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='513grapheme-stack.mu.html#L3'>grapheme-stack</a>) <span class="Special">&lt;-</span> copy _self
<span id="L10" class="LineNr"> 10 </span> <span class="PreProc">var</span> d/<span class="muRegEdi">edi</span>: (addr handle array code-point-utf8) <span class="Special">&lt;-</span> get self, data
<span id="L11" class="LineNr"> 11 </span> populate d, n
<span id="L12" class="LineNr"> 12 </span> <span class="PreProc">var</span> top/eax: (addr int) <span class="Special">&lt;-</span> get self, top
<span id="L13" class="LineNr"> 13 </span> copy-to *top, <span class="Constant">0</span>
<span id="L14" class="LineNr"> 14 </span><span class="Delimiter">}</span>
<span id="L15" class="LineNr"> 15 </span>
<span id="L16" class="LineNr"> 16 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='513grapheme-stack.mu.html#L16'>clear-code-point-utf8-stack</a></span> _self: (addr <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack</a>) <span class="Delimiter">{</span>
<span id="L17" class="LineNr"> 17 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack</a>) <span class="Special">&lt;-</span> copy _self
<span id="L16" class="LineNr"> 16 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='513grapheme-stack.mu.html#L16'>clear-grapheme-stack</a></span> _self: (addr <a href='513grapheme-stack.mu.html#L3'>grapheme-stack</a>) <span class="Delimiter">{</span>
<span id="L17" class="LineNr"> 17 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='513grapheme-stack.mu.html#L3'>grapheme-stack</a>) <span class="Special">&lt;-</span> copy _self
<span id="L18" class="LineNr"> 18 </span> <span class="PreProc">var</span> top/eax: (addr int) <span class="Special">&lt;-</span> get self, top
<span id="L19" class="LineNr"> 19 </span> copy-to *top, <span class="Constant">0</span>
<span id="L20" class="LineNr"> 20 </span><span class="Delimiter">}</span>
<span id="L21" class="LineNr"> 21 </span>
<span id="L22" class="LineNr"> 22 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='513grapheme-stack.mu.html#L22'>code-point-utf8-stack-empty?</a></span> _self: (addr <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack</a>)<span class="PreProc"> -&gt; </span>_/eax: boolean <span class="Delimiter">{</span>
<span id="L23" class="LineNr"> 23 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack</a>) <span class="Special">&lt;-</span> copy _self
<span id="L22" class="LineNr"> 22 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='513grapheme-stack.mu.html#L22'>grapheme-stack-empty?</a></span> _self: (addr <a href='513grapheme-stack.mu.html#L3'>grapheme-stack</a>)<span class="PreProc"> -&gt; </span>_/eax: boolean <span class="Delimiter">{</span>
<span id="L23" class="LineNr"> 23 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='513grapheme-stack.mu.html#L3'>grapheme-stack</a>) <span class="Special">&lt;-</span> copy _self
<span id="L24" class="LineNr"> 24 </span> <span class="PreProc">var</span> top/eax: (addr int) <span class="Special">&lt;-</span> get self, top
<span id="L25" class="LineNr"> 25 </span> compare *top, <span class="Constant">0</span>
<span id="L26" class="LineNr"> 26 </span> <span class="Delimiter">{</span>
@ -94,14 +94,14 @@ if ('onhashchange' in window) {
<span id="L30" class="LineNr"> 30 </span> <span class="PreProc">return</span> <span class="Constant">0</span>/false
<span id="L31" class="LineNr"> 31 </span><span class="Delimiter">}</span>
<span id="L32" class="LineNr"> 32 </span>
<span id="L33" class="LineNr"> 33 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='513grapheme-stack.mu.html#L33'>code-point-utf8-stack-length</a></span> _self: (addr <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack</a>)<span class="PreProc"> -&gt; </span>_/eax: int <span class="Delimiter">{</span>
<span id="L34" class="LineNr"> 34 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack</a>) <span class="Special">&lt;-</span> copy _self
<span id="L33" class="LineNr"> 33 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='513grapheme-stack.mu.html#L33'>grapheme-stack-length</a></span> _self: (addr <a href='513grapheme-stack.mu.html#L3'>grapheme-stack</a>)<span class="PreProc"> -&gt; </span>_/eax: int <span class="Delimiter">{</span>
<span id="L34" class="LineNr"> 34 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='513grapheme-stack.mu.html#L3'>grapheme-stack</a>) <span class="Special">&lt;-</span> copy _self
<span id="L35" class="LineNr"> 35 </span> <span class="PreProc">var</span> top/eax: (addr int) <span class="Special">&lt;-</span> get self, top
<span id="L36" class="LineNr"> 36 </span> <span class="PreProc">return</span> *top
<span id="L37" class="LineNr"> 37 </span><span class="Delimiter">}</span>
<span id="L38" class="LineNr"> 38 </span>
<span id="L39" class="LineNr"> 39 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='513grapheme-stack.mu.html#L39'>push-code-point-utf8-stack</a></span> _self: (addr <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack</a>), _val: code-point-utf8 <span class="Delimiter">{</span>
<span id="L40" class="LineNr"> 40 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack</a>) <span class="Special">&lt;-</span> copy _self
<span id="L39" class="LineNr"> 39 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='513grapheme-stack.mu.html#L39'>push-grapheme-stack</a></span> _self: (addr <a href='513grapheme-stack.mu.html#L3'>grapheme-stack</a>), _val: code-point-utf8 <span class="Delimiter">{</span>
<span id="L40" class="LineNr"> 40 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='513grapheme-stack.mu.html#L3'>grapheme-stack</a>) <span class="Special">&lt;-</span> copy _self
<span id="L41" class="LineNr"> 41 </span> <span class="PreProc">var</span> top-addr/<span class="muRegEcx">ecx</span>: (addr int) <span class="Special">&lt;-</span> get self, top
<span id="L42" class="LineNr"> 42 </span> <span class="PreProc">var</span> data-ah/<span class="muRegEdx">edx</span>: (addr handle array code-point-utf8) <span class="Special">&lt;-</span> get self, data
<span id="L43" class="LineNr"> 43 </span> <span class="PreProc">var</span> data/eax: (addr array code-point-utf8) <span class="Special">&lt;-</span> <a href='120allocate.subx.html#L235'>lookup</a> *data-ah
@ -112,8 +112,8 @@ if ('onhashchange' in window) {
<span id="L48" class="LineNr"> 48 </span> add-to *top-addr, <span class="Constant">1</span>
<span id="L49" class="LineNr"> 49 </span><span class="Delimiter">}</span>
<span id="L50" class="LineNr"> 50 </span>
<span id="L51" class="LineNr"> 51 </span><span class="PreProc">fn</span> <span class="muFunction"><a href='513grapheme-stack.mu.html#L51'>pop-code-point-utf8-stack</a></span> _self: (addr <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack</a>)<span class="PreProc"> -&gt; </span>_/eax: code-point-utf8 <span class="Delimiter">{</span>
<span id="L52" class="LineNr"> 52 </span> <span class="PreProc">var</span> self/<span class="muRegEsi">esi</span>: (addr <a href='513grapheme-stack.mu.html#L3'>code-point-utf8-stack