diff options
| author | 2026-10-14 16:09:07 +0330 | |
|---|---|---|
| committer | 2026-10-14 16:09:07 +0330 | |
| commit | e228e7609929763d5acddb728ba543832fcffc6a (patch) | |
| tree | 9b4ecc4d46bf38e8d20234d631a6d41543daa211 /src/compiler/stmt.zc | |
| parent | merge: memdebug obj_base via size classes (diff) | |
| parent | bounds checking: constant loop bound proof works, plain-op fixed-array check,... (diff) | |
merge bounds checking
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 3ecb81b..a67b931 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 |
