diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-09-07 21:21:31 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-09-07 21:21:31 -0700 |
commit | 137cde5bfae7104c97b0f48277480eb78ced4ff1 (patch) | |
tree | 1d2ceb7ab07a0dde2e8c4a3e081f5eb09d9b6319 /apps/browse/file-state.mu | |
parent | dce4efd268b9080d4e29b34699b83a124dfcfb0e (diff) | |
download | mu-137cde5bfae7104c97b0f48277480eb78ced4ff1.tar.gz |
6750
Diffstat (limited to 'apps/browse/file-state.mu')
-rw-r--r-- | apps/browse/file-state.mu | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/apps/browse/file-state.mu b/apps/browse/file-state.mu deleted file mode 100644 index d42bf8bf..00000000 --- a/apps/browse/file-state.mu +++ /dev/null @@ -1,45 +0,0 @@ -type file-state { - source: (handle buffered-file) - eof?: boolean -} - -fn init-file-state _self: (addr file-state), filename: (addr array byte) { - var self/eax: (addr file-state) <- copy _self - load-file self, filename - var eof/eax: (addr boolean) <- get self, eof? - copy-to *eof, 0 # false -} - -fn load-file _self: (addr file-state), filename: (addr array byte) { - var self/eax: (addr file-state) <- copy _self - var out/esi: (addr handle buffered-file) <- get self, source - open filename, 0, out # 0 = read mode -} - -fn next-char _self: (addr file-state) -> result/eax: byte { - var self/ecx: (addr file-state) <- copy _self - var source/eax: (addr handle buffered-file) <- get self, source - var in/eax: (addr buffered-file) <- lookup *source - result <- read-byte-buffered in - # if result == EOF, set eof? - compare result, 0xffffffff # EOF marker - { - var eof/ecx: (addr boolean) <- get self, eof? - copy-to *eof, 1 # true - } -} - -fn done-reading? _self: (addr file-state) -> result/eax: boolean { - var self/eax: (addr file-state) <- copy _self - var eof/eax: (addr boolean) <- get self, eof? - result <- copy *eof -} - -fn dump in: (addr buffered-file) { - var c/eax: byte <- read-byte-buffered in - compare c, 0xffffffff # EOF marker - break-if-= - var g/eax: grapheme <- copy c - print-grapheme 0, g - loop -} |