Skip to content

Commit

Permalink
GH-14 Refactor _block and _buffer code.
Browse files Browse the repository at this point in the history
  • Loading branch information
SirWumpus committed Aug 9, 2024
1 parent 624bb7d commit 158fe99
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/post4.c
Original file line number Diff line number Diff line change
Expand Up @@ -2387,13 +2387,19 @@ _blk: P4_PUSH(ctx->ds, (P4_Cell *) &ctx->input.blk);
NEXT;

// ( u -- aaddr )
_block: w = P4_TOP(ctx->ds);
if ((rc = p4BlockBuffer(ctx, w.u, 1)) != P4_THROW_OK) {
_block: x.u = 1;

_block_buffer: w = P4_TOP(ctx->ds);
if ((rc = p4BlockBuffer(ctx, w.u, x.u)) != P4_THROW_OK) {
THROW(rc);
}
P4_TOP(ctx->ds).s = ctx->block.buffer;
NEXT;

// ( u -- aaddr )
_buffer: x.u = 0;
goto _block_buffer;

// ( caddr u -- bool )
_block_open: w = P4_POP(ctx->ds);
x = P4_TOP(ctx->ds);
Expand All @@ -2415,14 +2421,6 @@ _blocks: if (fstat(ctx->block_fd, &sb) != 0) {
P4_PUSH(ctx->ds, w);
NEXT;
}
// ( u -- aaddr )
_buffer: w = P4_TOP(ctx->ds);
if ((rc = p4BlockBuffer(ctx, w.u, 0)) != P4_THROW_OK) {
THROW(rc);
}
P4_TOP(ctx->ds).s = ctx->block.buffer;
NEXT;

// ( -- )
_empty_buffers: ctx->block.state = P4_BLOCK_FREE;
/*@fallthrough@*/
Expand Down

0 comments on commit 158fe99

Please sign in to comment.