From bfcc0f858aa324739ad645e2056d73a47ab66f82 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Fri, 3 Apr 2020 12:35:53 -0700 Subject: 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. --- 064write-byte.subx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to '064write-byte.subx') diff --git a/064write-byte.subx b/064write-byte.subx index 13da5722..b134a2a8 100644 --- a/064write-byte.subx +++ b/064write-byte.subx @@ -16,7 +16,7 @@ $Stdout->buffer: 0/imm32 # current read index 0/imm32 - # length + # size 8/imm32 # data 00 00 00 00 00 00 00 00 # 8 bytes @@ -41,7 +41,7 @@ write-byte-buffered: # f: (addr buffered-file), n: int 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 . # copy *(ebp+8) to edi # ecx = f->write 8b/copy 1/mod/*+disp8 7/rm32/edi . . . 1/r32/ecx 4/disp8 . # copy *(edi+4) to ecx - # if (f->write >= f->length) flush and clear f's stream + # if (f->write >= f->size) flush and clear f's stream 3b/compare 1/mod/*+disp8 7/rm32/edi . . . 1/r32/ecx 0xc/disp8 . # compare ecx with *(edi+12) 7c/jump-if-< $write-byte-buffered:to-stream/disp8 # . flush(f) @@ -216,7 +216,7 @@ append-byte: # f: (addr stream byte), n: int 8b/copy 1/mod/*+disp8 5/rm32/ebp . . . 7/r32/edi 8/disp8 . # copy *(ebp+8) to edi # ecx = f->write 8b/copy 0/mod/indirect 7/rm32/edi . . . 1/r32/ecx . . # copy *edi to ecx - # if (f->write >= f->length) abort + # if (f->write >= f->size) abort 3b/compare 1/mod/*+disp8 7/rm32/edi . . . 1/r32/ecx 8/disp8 . # compare ecx with *(edi+8) 7d/jump-if->= $append-byte:abort/disp8 $append-byte:to-stream: @@ -288,7 +288,7 @@ _test-output-stream: # (stream byte) 0/imm32 # current read index 0/imm32 - # length + # size 0x400/imm32 # 1024 bytes # data (64 lines x 16 bytes/line) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -365,7 +365,7 @@ $_test-output-buffered-file->buffer: 0/imm32 # current read index 0/imm32 - # length + # size 6/imm32 # data 00 00 00 00 00 00 # 6 bytes @@ -396,7 +396,7 @@ $_test-error-buffered-file->buffer: 0/imm32 # current read index 0/imm32 - # length + # size 6/imm32 # data 00 00 00 00 00 00 # 6 bytes -- cgit 1.4.1-2-gfad0