aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 16:25:05 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 16:25:05 +0330
commit8a7092df7b7fc8a5eb4f02ef14588246bd111daf (patch)
tree0d9d28ca93ccbddb1f99cb02b88ed466e0ade481 /src/tools
parenthistory: 43-stdlib notes point forward to zc0 no longer reserving u, m and d (diff)
parentmerge bounds checking (diff)
Merge branch 'main' into work/xref
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 782d548..664ea79 100644
--- a/src/tools/zc0.c
+++ b/src/tools/zc0.c
@@ -492,7 +492,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;
@@ -798,7 +798,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();
@@ -1048,6 +1048,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; }