about summary refs log tree commit diff stats
path: root/071read-line.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-04-03 12:35:53 -0700
committerKartik Agaram <vc@akkartik.com>2020-04-03 12:35:53 -0700
commitbfcc0f858aa324739ad645e2056d73a47ab66f82 (patch)
tree24a22e364b2c1d535013c604b7a9620a31606e71 /071read-line.subx
parentf730f2f2c7934f52091a848b71f9031ea99e2377 (diff)
downloadmu-bfcc0f858aa324739ad645e2056d73a47ab66f82.tar.gz
6182 - start of support for safe handles
So far it's unclear how to do this in a series of small commits. Still
nibbling around the edges. In this commit we standardize some terminology:

The length of an array or stream is denominated in the high-level elements.
The _size_ is denominated in bytes.

The thing we encode into the type is always the size, not the length.

There's still an open question of what to do about the Mu `length` operator.
I'd like to modify it to provide the length. Currently it provides the
size. If I can't fix that I'll rename it.
Diffstat (limited to '071read-line.subx')
-rw-r--r--071read-line.subx8
1 files changed, 4 insertions, 4 deletions
diff --git a/071read-line.subx b/071read-line.subx
index d4fe9e68..b230c9ca 100644
--- a/071read-line.subx
+++ b/071read-line.subx
@@ -9,7 +9,7 @@
 read-line-buffered:  # f: (addr buffered-file), s: (addr stream byte)
     # pseudocode:
     #   while true
-    #     if (s->write >= s->length) abort
+    #     if (s->write >= s->size) abort
     #     if (f->read >= f->write) populate stream from file
     #     if (f->write == 0) break
     #     AL = f->data[f->read]
@@ -35,7 +35,7 @@ read-line-buffered:  # f: (addr buffered-file), s: (addr stream byte)
     # edx = s->write
     8b/copy                         0/mod/indirect  7/rm32/edi    .           .             .           2/r32/edx   .               .                 # copy *edi to edx
 $read-line-buffered:loop:
-    # if (s->write >= s->length) abort
+    # if (s->write >= s->size) abort
     3b/compare                      1/mod/*+disp8   7/rm32/edi    .           .             .           2/r32/edx   8/disp8         .                 # compare edx with *(edi+8)
     7d/jump-if->=  $read-line-buffered:abort/disp8
     # if (f->read >= f->write) populate stream from file
@@ -219,7 +219,7 @@ test-read-line-buffered-reads-final-line-until-Eof:
 read-line:  # f: (addr stream byte), s: (addr stream byte)
     # pseudocode:
     #   while true
-    #     if (s->write >= s->length) abort
+    #     if (s->write >= s->size) abort
     #     if (f->read >= f->write) break
     #     AL = f->data[f->read]
     #     s->data[s->write] = AL
@@ -244,7 +244,7 @@ read-line:  # f: (addr stream byte), s: (addr stream byte)
     # edx = s->write
     8b/copy                         0/mod/indirect  7/rm32/edi    .           .             .           2/r32/edx   .               .                 # copy *edi to edx
 $read-line:loop:
-    # if (s->write >= s->length) abort
+    # if (s->write >= s->size) abort
     3b/compare                      1/mod/*+disp8   7/rm32/edi    .           .             .           2/r32/edx   8/disp8         .                 # compare edx with *(edi+8)
     0f 8d/jump-if->=  $read-line:abort/disp32
     # if (f->read >= f->write) break