about summary refs log tree commit diff stats
path: root/070new-stream.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 /070new-stream.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 '070new-stream.subx')
-rw-r--r--070new-stream.subx8
1 files changed, 4 insertions, 4 deletions
diff --git a/070new-stream.subx b/070new-stream.subx
index 76d2a516..5474175b 100644
--- a/070new-stream.subx
+++ b/070new-stream.subx
@@ -11,7 +11,7 @@ new-stream:  # ad: (addr allocation-descriptor), length: int, elemsize: int -> a
     89/copy                         3/mod/direct    5/rm32/ebp    .           .             .           4/r32/esp   .               .                 # copy esp to ebp
     # . save registers
     52/push-edx
-    # var n/eax: int = elemsize * length + 12 (for read, write and length)
+    # var n/eax: int = elemsize * length + 12 (for read, write and size)
     # . eax = elemsize
     8b/copy                         1/mod/*+disp8   5/rm32/ebp    .           .             .           0/r32/eax   0x10/disp8      .                 # copy *(ebp+16) to eax
     # . eax *= length
@@ -32,7 +32,7 @@ new-stream:  # ad: (addr allocation-descriptor), length: int, elemsize: int -> a
     e8/call  allocate/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               8/imm32           # add to esp
-    # eax->length = elemsize*length
+    # eax->size = elemsize*length
     89/copy                         1/mod/*+disp8   0/rm32/eax    .           .             .           2/r32/edx   8/disp8         .                 # copy edx to *(eax+8)
     # clear-stream(eax)
     # . . push args
@@ -100,9 +100,9 @@ test-new-stream:
     e8/call  check-ints-equal/disp32
     # . . discard args
     81          0/subop/add         3/mod/direct    4/rm32/esp    .           .             .           .           .               0xc/imm32         # add to esp
-    # check-ints-equal(eax->length, 6, msg)
+    # check-ints-equal(eax->size, 6, msg)
     # . . push args
-    68/push  "F - test-new-stream: sets length correctly"/imm32
+    68/push  "F - test-new-stream: sets size correctly"/imm32
     68/push  6/imm32
     ff          6/subop/push        1/mod/*+disp8   0/rm32/eax    .           .             .           .           .               8/disp8           # push *(eax+8)
     # . . call