diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-10-01 20:40:22 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-10-01 20:40:22 -0700 |
commit | d75b71297426ee2d63d5630d1ef9469de48aca84 (patch) | |
tree | 0d4c517526770343822d4f409a8e9c1b7ac0e51e /prototypes/browse/20/file-state.mu | |
parent | f3ca0e3cb33d6c34dbe4c6941598d16d140be206 (diff) | |
download | mu-d75b71297426ee2d63d5630d1ef9469de48aca84.tar.gz |
6923
Diffstat (limited to 'prototypes/browse/20/file-state.mu')
-rw-r--r-- | prototypes/browse/20/file-state.mu | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/prototypes/browse/20/file-state.mu b/prototypes/browse/20/file-state.mu deleted file mode 100644 index d42bf8bf..00000000 --- a/prototypes/browse/20/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 -} |