about summary refs log tree commit diff stats
path: root/055stream.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 /055stream.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 '055stream.subx')
-rw-r--r--055stream.subx8
1 files changed, 4 insertions, 4 deletions
diff --git a/055stream.subx b/055stream.subx
index 15d82ce6..84d0580b 100644
--- a/055stream.subx
+++ b/055stream.subx
@@ -3,10 +3,10 @@
 # A stream looks like this:
 #   write: int  # index at which writes go
 #   read: int  # index that we've read until
-#   data: (array byte)  # prefixed by length as usual
+#   data: (array byte)  # prefixed by size as usual
 #
 # some primitives for operating on streams:
-#   - clear-stream (clears everything but the data length)
+#   - clear-stream (clears everything but the data size)
 #   - rewind-stream (resets read pointer)
 
 == code
@@ -23,9 +23,9 @@ clear-stream:  # f: (addr stream byte)
     51/push-ecx
     # eax = f
     8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .                         0/r32/eax   8/disp8         .                 # copy *(ebp+8) to eax
-    # var count/ecx: int = f->length
+    # var count/ecx: int = f->size
     8b/copy                         1/mod/*+disp8   0/rm32/eax    .           .             .           1/r32/ecx   8/disp8         .                 # copy *(eax+8) to ecx
-    # var max/ecx: (addr byte) = &f->data[f->length]
+    # var max/ecx: (addr byte) = &f->data[f->size]
     8d/copy-address                 1/mod/*+disp8   4/rm32/sib    0/base/eax  1/index/ecx   .           1/r32/ecx   0xc/disp8       .                 # copy eax+ecx+12 to ecx
     # f->write = 0
     c7          0/subop/copy        0/mod/direct    0/rm32/eax    .           .             .           .           .               0/imm32           # copy to *eax