aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-25 15:00:52 +0100
committereunhhu <[email protected]>2026-09-25 15:00:52 +0100
commitf35ded451b1da147613ece18e2b334d0966b24f1 (patch)
treec5d9284a5ca33768c07b983bcee177c228648ddc /src
parentb9ddfdd4cde05b6a520650c7b50ace0af4c5c019 (diff)
downloadaup-f35ded451b1da147613ece18e2b334d0966b24f1.tar.gz
aup-f35ded451b1da147613ece18e2b334d0966b24f1.zip
Emit Pure module format v5
Pure now loads only v5 modules, where a view entry's type is one byte followed by the table it belongs to. Plain views encode as before, so the output changes only in its magic. The view limit follows Pure's to 64.
Diffstat (limited to 'src')
-rw-r--r--src/compile.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/compile.c b/src/compile.c
index 7305937..f990399 100644
--- a/src/compile.c
+++ b/src/compile.c
@@ -7,8 +7,8 @@
#include <stdlib.h>
#include <string.h>
-/* Limits and opcodes of Pure module format v4. */
-enum { STATES = 32, INPUTS = 32, VIEWS = 24, HANDLERS = 64, CODE = 512, STACK = 64, NAME = 32,
+/* Limits and opcodes of Pure module format v5. */
+enum { STATES = 32, INPUTS = 32, VIEWS = 64, HANDLERS = 64, CODE = 512, STACK = 64, NAME = 32,
DEPTH = 64, FIELDS = 32, COLLECTIONS = 1, CONSTANTS = 64, CONSTANT_BYTES = 8192,
RECORDS = 8, RECORD_FIELDS = 64, FIELDS_PER_RECORD = 16 };
enum { CONST, LOAD, DT, ADD, SUB, MUL, DIV, NEG, LT, LE, GT, GE, EQ, NE, AND, OR, NOT,
@@ -944,7 +944,7 @@ static void declaration(Compiler *c) {
} else if (!strcmp(kind.text, "view")) {
Token name = expect_name(c, "view name");
declare(c, &name);
- if (c->views == VIEWS) fail_at(c, name.line, name.column, "at most 24 views are allowed");
+ if (c->views == VIEWS) fail_at(c, name.line, name.column, "at most 64 views are allowed");
expect(c, "=", "'='");
memcpy(c->view_names[c->views], name.text, NAME);
c->view_value[c->views++] = expression(c, 0, false);
@@ -1468,7 +1468,7 @@ static void generate(Compiler *c, unsigned char **module, size_t *size) {
*size = 40 + 16u * c->states + 12u * c->collections + 16u * c->input_count + 8u * fields + 8u * c->constants +
8u * c->record_count + 16u * c->record_fields + 16u * c->views + 12u * c->handler_count + 16u * c->code_count + used + c->constant_used;
unsigned char *p = *module = allocate(c, *size);
- memcpy(p, "PUREMOD4", 8);
+ memcpy(p, "PUREMOD5", 8);
put16(p + 8, c->states);
put16(p + 10, c->input_count);
put16(p + 12, c->views);