From e8b3499289022c8729900a58ed218d961a85fec8 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Sun, 18 Oct 2026 18:52:48 +0100 Subject: Module format and executor: 027's 4b-1, a record field holding bytes (type 5): held as a text is but for UTF-8, its default a constant; a function's bytes in a signature this type too (PURE_SIGNATURE_BYTES gone); no list keyed by bytes; replaced, a text field becomes a bytes field keeping its value (pure_cell_as, kinds_carry); images' headers take its kind; the JSON edge reads it from a string; pure-run shows it as hex; an append asks a record's fields held as bytes from a mask the load makes (record_held) instead of each field's type twice, so b32 runs fewer instructions than b30 (BFS without batches -1.05%, join -0.25%, BFS with batches -0.36%, the rest within 0.04%; the bank's queries s30 against s32 -0.01% to +0.30%); unit test bytes_fields (bytes not UTF-8, a text field replaced by a bytes field, three refused); server_trees with a bytes field; 008 and 027 --- cli/pure-run.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'cli/pure-run.c') diff --git a/cli/pure-run.c b/cli/pure-run.c index dceb841..8783f84 100644 --- a/cli/pure-run.c +++ b/cli/pure-run.c @@ -16,8 +16,8 @@ * (type gives a text input its bytes, message a message input its payload, laid out as the module says; * message NAME @PATH gives it the bytes of the file at PATH, of any size.) * Text states and text views print as JSON strings; cursors as byte positions; - * lists as arrays of objects; indices as positions; a table view as an array - * with an object of its columns per row. A failed view or cell is null. */ + * lists as arrays of objects (a bytes field as a string of its hex digits); indices as positions; a table view as an + * array with an object of its columns per row. A failed view or cell is null. */ /* time MS sets the time events see (milliseconds since 1970); tick NAME is a timer's tick. */ static bool load(const char *path, PureModule *module) { @@ -62,7 +62,7 @@ static void show_value_items(const PureModule *m, uint32_t record, const unsigne for (unsigned f = 0; f < r->count && at <= size; ++f) { uint8_t type = m->record_field_type[r->first + f]; PureCell cell = {0}; - if (type == PURE_RECORD_TEXT || type == PURE_RECORD_LIST) { + if (pure_record_bytes(type) || type == PURE_RECORD_LIST) { cell.size = size - at >= 4 ? le32(bytes + at) : 0; cell.text = (unsigned char *)bytes + at + 4; at += 4 + cell.size; @@ -85,7 +85,11 @@ static void show_cell(const PureModule *m, uint32_t field, PureCell cell, bool k else if (type == PURE_RECORD_NUMBER) printf("%.17g", cell.num); else if (type == PURE_RECORD_LIST && kept) show_value_items(m, (uint32_t)m->record_field_default[field].i64, cell.text, cell.size); else if (type == PURE_RECORD_LIST) printf("%" PRId64, cell.i64); /* an event's list: its number among the event's */ - else { + else if (type == PURE_RECORD_BYTES) { + putchar('"'); + for (size_t i = 0; i < cell.size; ++i) printf("%02x", cell.text[i]); + putchar('"'); + } else { putchar('"'); json_span(NULL, (PureSpan){cell.text, cell.size}); putchar('"'); -- cgit v1.2.3