aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 15:58:58 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 15:58:58 +0330
commitd55b5fdf92a674a6495878f97a09e95bafdcba3f (patch)
treee811149b65640a3e253e6ebdce41affddb53ac37 /src/tools
parentmerge line tables (diff)
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
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/build.zc3
-rw-r--r--src/tools/zc0.c5
2 files changed, 6 insertions, 2 deletions
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; }