diff options
| author | 2026-10-14 15:58:58 +0330 | |
|---|---|---|
| committer | 2026-10-14 15:58:58 +0330 | |
| commit | d55b5fdf92a674a6495878f97a09e95bafdcba3f (patch) | |
| tree | e811149b65640a3e253e6ebdce41affddb53ac37 /src/compiler/stmt.zc | |
| parent | merge 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/compiler/stmt.zc')
| -rw-r--r-- | src/compiler/stmt.zc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/compiler/stmt.zc b/src/compiler/stmt.zc index 4dafe4f..505e466 100644 --- a/src/compiler/stmt.zc +++ b/src/compiler/stmt.zc @@ -323,7 +323,7 @@ int kw_for() { borrow_cleanup_since(borrow_mark); s0 = snap_push(); c0 = here; - ft_iv = -1; fs_ok = 0; fortest = 1; + ft_iv = -1; ft_ck = -1; fs_ok = 0; fortest = 1; if (!is_op(s_semi)) { if (tk == T_NUM && tv) { peek(); if (pk_tk == T_OP && pk_tv == s_semi) inf = 1; } c = borrow_condition(); @@ -344,6 +344,8 @@ int kw_for() { loop_push(st, s0); if (ft_iv >= 0 && ft_bd >= 0 && fs_ok && getlo(ft_iv) >= 0 && getln(ft_bd) >= 0) { lpfact[lsp - 1] = pfact(ft_iv, ft_bd, getln(ft_bd)); + } else if (ft_iv >= 0 && ft_ck >= 0 && fs_ok && getlo(ft_iv) >= 0) { // i < constant: proves a fixed array that long + lpfact[lsp - 1] = pfact(ft_iv, -1, 0 - ft_ck - 2); } substmt(); backedge(s0); @@ -724,6 +726,17 @@ int kw_unchecked() { return 0; } +// unbounded turns the index bounds checks off for one statement +int kw_unbounded() { + int old = fbnd; + stmtonly(); + next(); + fbnd = 0; + substmt(); + fbnd = old; + return 0; +} + // ---- asm blocks: raw vm words, one per token ---- // numbers push, -n pushes a negative number, #n emits a raw word, one-char |
