From d55b5fdf92a674a6495878f97a09e95bafdcba3f Mon Sep 17 00:00:00 2001 From: zinc Date: Wed, 14 Oct 2026 15:58:58 +0330 Subject: bounds checking: port agent/bounds-checking onto main 0879d0a; unbounded main in o3call, o3 tests expect no check, boundsrules, bounds_fixed, bounds_heap and zc0unbounded tests --- src/tools/build.zc | 3 +++ src/tools/zc0.c | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/tools') diff --git a/src/tools/build.zc b/src/tools/build.zc index b628a33..b2f838f 100644 --- a/src/tools/build.zc +++ b/src/tools/build.zc @@ -1,6 +1,9 @@ namespace; include rt, run; +// the build tool pokes at headers and raw memory on purpose and runs at full speed: no index bounds checks +unbounded; + // compiles the rest of stdin (after the backtick) as a genome image at GORG // and writes it to stdout as little-endian 64-bit words. diff --git a/src/tools/zc0.c b/src/tools/zc0.c index 5846e22..af85ff8 100644 --- a/src/tools/zc0.c +++ b/src/tools/zc0.c @@ -463,7 +463,7 @@ static int notatype(void) static const char *w[] = { "return", "if", "else", "while", "for", "do", "break", "continue", "let", "var", "fn", "const", "enhance", "struct", "enum", "asm", "switch", "case", "default", "immediate", "type", "include", "as", "in", "new", "sizeof", "typeof", - "o3", "unchecked", 0 }; + "o3", "unchecked", "unbounded", 0 }; int i; if (tk != T_ID) return 0; for (i = 0; w[i]; i++) if (!strcmp(ts, w[i])) return 1; @@ -769,7 +769,7 @@ static void stmt(void) expect(";"); return; } } - if (accept("unchecked")) { stmt(); return; } + if (accept("unchecked") || accept("unbounded")) { stmt(); return; } if (accept("if")) { expect("("); expr(); rval(); ftest(); expect(")"); a = here; lit(0); op(O_JZ); stmt(); @@ -1014,6 +1014,7 @@ static void top1(void) } if (accept("embed")) { embeddecl(0); return; } { + if (accept("unbounded")) { if (accept(";")) return; top1(); return; } if (accept("unchecked")) { top1(); return; } if (accept("fn")) { fndef(0, 0); return; } if (accept("const")) { optype(); do { char *n = ident(); if (dsn && !dnm[0]) strcpy(dnm, n); expect("="); add(n, K_CONST, cexpr()); } while (accept(",")); expect(";"); return; } -- cgit v1.2.3