aboutsummaryrefslogtreecommitdiffstats
path: root/core/module.h
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-13 05:08:06 +0100
committereunhhu <[email protected]>2026-10-13 05:08:06 +0100
commit5a44af0308017f4e7b54a8ff6ccdc797b5d94015 (patch)
tree18df52e099b435bf1397126e7638e3209b654e1f /core/module.h
parent0b39099c536ac01eaa7e1867db0cdb515873b543 (diff)
downloadpure-5a44af0308017f4e7b54a8ff6ccdc797b5d94015.tar.gz
pure-5a44af0308017f4e7b54a8ff6ccdc797b5d94015.zip
Module format: bits and bytes (design 027's stage 1): I64_BITS (and, or, xor, a left shift as a times 2^b failing as overflow past the range, a right shift as floor(a / 2^b), a count outside 0-63 failing as limit: integers in two's complement without end), BYTE_AT (the byte of any bytes value at a whole position, a number or an i64, else limit), BYTES_OF (a list of one i64 field as bytes, a value outside 0-255 failing as limit) and INDEX_AT (a list's item at a position, not_found where there is none); the fold-shape and batch analyses count their arity and the lists they read; unit tests of the ends (27 bit cases, 11 reads of a constant's and a text state's bytes, 7 refused)
Diffstat (limited to 'core/module.h')
-rw-r--r--core/module.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/core/module.h b/core/module.h
index e10894d..b230fc3 100644
--- a/core/module.h
+++ b/core/module.h
@@ -43,6 +43,7 @@ typedef enum {
PURE_OP_I64_ADD, PURE_OP_I64_SUB, PURE_OP_I64_MUL, PURE_OP_I64_DIV, PURE_OP_I64_MOD, PURE_OP_I64_NEG,
PURE_OP_I64_COMPARE, PURE_OP_I64_MIN, PURE_OP_I64_MAX, PURE_OP_I64_FROM, PURE_OP_NUM_FROM,
PURE_OP_LOOP, PURE_OP_BREAK,
+ PURE_OP_I64_BITS, PURE_OP_BYTE_AT, PURE_OP_BYTES_OF, PURE_OP_INDEX_AT,
PURE_OP_COUNT
} PureOpcode;
/* A bool is its own type (docs/design/016-bool-and-i64.md), held as a
@@ -59,7 +60,19 @@ typedef enum {
* DIVIDE by zero; COMPARE takes a relation as TEXT_COMPARE does and gives a
* bool), I64_FROM makes one of a whole number in range and NUM_FROM a
* number of one within 2^53 (else LIMIT). LOAD, STORE, the item and local
- * opcodes, FIELD and SEND move them as they move numbers. */
+ * opcodes, FIELD and SEND move them as they move numbers.
+ * I64_BITS computes on two i64s as on integers in two's complement without
+ * end (docs/design/027): its argument says how (PureBits). AND, OR and XOR
+ * work bit by bit; LEFT is a * 2^b, failing as OVERFLOW past the range;
+ * RIGHT is floor(a / 2^b); a shift by b outside 0-63 fails as LIMIT.
+ * BYTE_AT gives the byte of a bytes value at a position (argument 0: a
+ * number, 1: an i64) as an i64 0-255, failing as LIMIT where there is none
+ * (not a whole number, or outside the value). BYTES_OF makes the bytes of a
+ * list state whose record is one i64 field, an item a byte (a value outside
+ * 0-255 fails as LIMIT). INDEX_AT makes the index of a list state's item at
+ * a position (a number), failing as LIMIT if it is not a whole number and
+ * as NOT_FOUND where there is no item. */
+typedef enum { PURE_BITS_AND, PURE_BITS_OR, PURE_BITS_XOR, PURE_BITS_LEFT, PURE_BITS_RIGHT } PureBits;
/* A local: one of an event's PURE_MODULE_LOCALS slots, 0 when the event
* begins and never saved. LOCAL_LOAD and LOCAL_STORE name the slot (bits
* 0-7), what it holds (bits 8-15: 0 a number, 1 an index, 2 a bool) and an index's