aboutsummaryrefslogtreecommitdiffstats
path: root/core/module.h
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-18 18:52:48 +0100
committereunhhu <[email protected]>2026-10-18 18:52:48 +0100
commite8b3499289022c8729900a58ed218d961a85fec8 (patch)
treefef2531be1dfc5a1568c3e2545430a8d5718d26f /core/module.h
parent531200a6c24842784fad68102878c3ab77391b13 (diff)
downloadpure-e8b3499289022c8729900a58ed218d961a85fec8.tar.gz
pure-e8b3499289022c8729900a58ed218d961a85fec8.zip
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
Diffstat (limited to 'core/module.h')
-rw-r--r--core/module.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/core/module.h b/core/module.h
index 349c4d2..d23cb49 100644
--- a/core/module.h
+++ b/core/module.h
@@ -137,7 +137,7 @@ enum { PURE_FORMAT_WIDTH = 8, PURE_FORMAT_ZEROS = 1 << 16, PURE_FORMAT_FORM = 17
* point), failing as LIMIT where no character begins there; CHAR makes the
* text of a code point, failing as LIMIT outside 0-0x10FFFF and as ENCODING
* for a surrogate. */
-enum { PURE_MODULE_FUNCTIONS = 64, PURE_MODULE_SIGNATURES = 1024, PURE_SIGNATURE_BYTES = 5 };
+enum { PURE_MODULE_FUNCTIONS = 64, PURE_MODULE_SIGNATURES = 1024 };
/* What a call's frame counts in the event's room: a table, as gas is, not the implementation's sizes (each at least
* what it stands for), so a module's calls fail at the same depth wherever and on whatever build they run: so much a
* frame, a value of its stack's height, a local, a loop it nests, a list of its own, a held value and a register. */
@@ -237,8 +237,12 @@ static inline uint8_t pure_value_kind(uint8_t state_type) {
return state_type == PURE_STATE_NUM ? PURE_CELL_NUMBER : state_type == PURE_STATE_BOOL ? PURE_CELL_BOOL :
state_type == PURE_STATE_I64 ? PURE_CELL_INTEGER : 0xFF;
}
-/* A record field: a number, a text (its default a constant), a bool or an i64. */
-typedef enum { PURE_RECORD_NUMBER = 0, PURE_RECORD_TEXT = 1, PURE_RECORD_BOOL = 2, PURE_RECORD_I64 = 3, PURE_RECORD_LIST = 4 } PureRecordType;
+/* A record field: a number, a text (its default a constant), a bool, an i64, a list (027's 2b) or bytes (4b: its
+ * default a constant too, held as a text is but for UTF-8). */
+typedef enum { PURE_RECORD_NUMBER = 0, PURE_RECORD_TEXT = 1, PURE_RECORD_BOOL = 2, PURE_RECORD_I64 = 3, PURE_RECORD_LIST = 4,
+ PURE_RECORD_BYTES = 5 } PureRecordType;
+/* A field held as bytes are: a text or bytes. */
+static inline bool pure_record_bytes(uint8_t type) { return type == PURE_RECORD_TEXT || type == PURE_RECORD_BYTES; }
/* A value's 8 bytes: a number (a bool's 0 or 1, a cursor's or an index's
* position too), or an integer. What a value is its state's or field's type
* says, and the verifier keeps to it: moves copy the bytes, and only what
@@ -291,7 +295,7 @@ typedef struct { union { double value; int64_t integer; }; uint32_t arg; uint8_t
typedef struct { uint32_t start, length; } PureBlock;
typedef struct { uint32_t event; PureBlock code; } PureHandler;
/* A function's block and its parameters' and results' types, from first among the module's signature items: a record
- * field's type (PureRecordType: a list's with its record) or PURE_SIGNATURE_BYTES. Set at load: the event's lists,
+ * field's type (PureRecordType: a list's with its record, bytes as PURE_RECORD_BYTES). Set at load: the event's lists,
* registers and held values each call has its own of (a bit each), the lists not an event's it changes (or a function
* it calls does), and its frame: its stack's height at most, its locals and its loops. */
typedef struct {
@@ -393,6 +397,7 @@ typedef struct {
PureValue record_field_default[PURE_MODULE_RECORD_FIELDS]; /* a number (a bool's 0 or 1), an i64, a text constant's index
* or a list's record (LIST, its i64) */
bool record_nested[PURE_MODULE_RECORDS]; /* a record with a LIST field (set at load) */
+ uint16_t record_held[PURE_MODULE_RECORDS]; /* its fields held as bytes are (pure_record_bytes), a bit each (set at load) */
uint16_t functions;
PureFunction function[PURE_MODULE_FUNCTIONS];
uint8_t signature_type[PURE_MODULE_SIGNATURES];