Phase 6A: .aji layers 3-4 (addressable values, lexical borrows, slices)
Owner rules: addressability is decided by lowering (a variable that is borrowed, indexed or written through a place gets frame storage in the entry block; otherwise SSA; by name, deterministic); borrows are bound only by 'ref r = place;' / 'mut r = place;' and live to the end of the block (borrow.end at every normal exit, including break/continue/return); no shadowing of an active borrow in the same scope; ref/mut as call arguments are temporaries ended after the call; *r only for scalar and struct referents, slices via s[i], s[a..b], s.len; writes *r = v, r.f = v, s[i] = v with the value evaluated first; split_at as the only multi-result binding; slice.copy(mut dst, ref src) as the only copy; [e; N] evaluates e once; byte strings as [u8; N] in frame storage with a fixed escape set; borrow.index.proven only for the verifier's own fact form (if i < s.len, same SSA values), otherwise checked. Diagnostics on lowered AIR are deduplicated per code and source location. aji lower --stats counts code only (no comment lines). Tests: 10 run (architecture goldens: value-only has no local.alloc, borrowed has local.alloc, proven indexing), 6 rejects incl. verifier-caught E2101 (aliasing; parent used after split_at). Expansion on these programs: 4-9x bytes, 2.2-6.6x lines.
This commit is contained in:
1 parent
0fdd04179b
commit
eca30f817a
28 files changed
+1157
-73
No files matched your search
+12
-3
@@ -37,9 +37,18 @@ pub fn checkFile(arena: std.mem.Allocator, file_name: []const u8, source: []cons
|
||||
.unimplemented => |what| return .{ .status = .unimplemented, .diagnostics = &.{}, .missing_stage = what },
|
||||
};
|
||||
var r = try checkAir(arena, file_name, lowered.air);
|
||||
const mapped = try arena.alloc(diag.Diagnostic, r.diagnostics.len);
|
||||
for (r.diagnostics, mapped) |d, *m| m.* = try frontend.mapDiagnostic(arena, d, file_name, lowered.lines);
|
||||
r.diagnostics = mapped;
|
||||
// One source construct often lowers to several AIR instructions that the
|
||||
// verifier reports separately: keep one diagnostic per code and source
|
||||
// location (the first).
|
||||
var mapped: std.ArrayList(diag.Diagnostic) = .empty;
|
||||
for (r.diagnostics) |d| {
|
||||
const m = try frontend.mapDiagnostic(arena, d, file_name, lowered.lines);
|
||||
const dup = for (mapped.items) |prev| {
|
||||
if (prev.code == m.code and prev.span.?.line == m.span.?.line and prev.span.?.col == m.span.?.col) break true;
|
||||
} else false;
|
||||
if (!dup) try mapped.append(arena, m);
|
||||
}
|
||||
r.diagnostics = mapped.items;
|
||||
r.lowered = lowered;
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user