harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit bef3effc920a5feb48827194155660504d0a9591
parent b4483abc7dfcad9a41860c158fa97084bc91adcc
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon, 11 Jan 2021 13:53:22 -0500

rt::compile: call write as often as necessary

And test for errors.

Diffstat:
Mrt/compile.ha | 9++++++++-
Msrc/gen.c | 3+--
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/rt/compile.ha b/rt/compile.ha @@ -18,7 +18,14 @@ export fn compile(src: str) int = { abort(); } else { close(pipefd[0]); - write(pipefd[1], src: *const char, len(src)); + + let buf = src: *const char: *const [*]u8; + for (let n = 0z; n < len(src)) { + let m = write(pipefd[1], &buf[n], len(src) - n); + assert(m: i64 > 0i64, "write(2) failed"); + n += m; + }; + close(pipefd[1]); wait4(child, &status, 0, null); }; diff --git a/src/gen.c b/src/gen.c @@ -987,8 +987,7 @@ gen_expr_measure(struct gen_context *ctx, gen_expression(ctx, expr->measure.value, &ptr); constl(&temp, builtin_type_size.size); pushi(ctx->current, &ptr, Q_ADD, &ptr, &temp, NULL); - qval_deref(&ptr); - gen_load(ctx, out, &ptr, false); + pushi(ctx->current, out, Q_LOADL, &ptr, NULL); break; default: assert(0); // Invariant