diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-10-26 22:35:20 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-10-26 23:45:40 -0700 |
commit | 0f9a65dc0d10d93319eacf8ccff75a068e5f97a8 (patch) | |
tree | a34427229e12d9cbea59d71d4a94825ee24f4c85 /410file.mu | |
parent | f3d1929033856ac12db84435c317c5a288f898b3 (diff) | |
download | mu-0f9a65dc0d10d93319eacf8ccff75a068e5f97a8.tar.gz |
7120 - tile: array of lines from file
Requires a quick hacky change to Mu compiler.
Diffstat (limited to '410file.mu')
-rw-r--r-- | 410file.mu | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/410file.mu b/410file.mu new file mode 100644 index 00000000..970407cf --- /dev/null +++ b/410file.mu @@ -0,0 +1,20 @@ +fn read-lines in: (addr buffered-file), out: (addr handle array (handle array byte)) { + var stream: (stream (handle array byte) 0x10) + var stream-a/edi: (addr stream (handle array byte)) <- address stream + var line: (stream byte 0x10) + var line-a/esi: (addr stream byte) <- address line + { + clear-stream line-a + read-line-buffered in, line-a + var done?/eax: boolean <- stream-empty? line-a + compare done?, 0 # false + break-if-!= +#? print-string 0, "AAA\n" + var h: (handle array byte) + var ah/eax: (addr handle array byte) <- address h + stream-to-array line-a, ah + write-to-stream stream-a, ah + loop + } + stream-to-array stream-a, out +} |