tiny.smg.SourceLineIndex
Defined in lines.
API (13)
Actions
Public operations.
Types and contracts
Public types and contracts.
Fields and members
Public fields and members.
Source
Source: tools/smg/src/lines.zig:4
zig
pub const SourceLines = struct { pub const Limits = struct { source: []const u8, }; pub const Capacity = struct { starts: usize, bytes: usize, pub fn derive(limits: Limits) error{CapacityOverflow}!Capacity { const starts = try logicalLineCount(std.mem.count(u8, limits.source, "\n")); return .{ .starts = starts, .bytes = try sourceLineBytes(starts), }; } }; pub const InitError = std.mem.Allocator.Error || error{CapacityOverflow}; pub const claim: alloc_phase.capacity.Declaration = .{ .source = .{ .id = "smg.source_line_index", .kind = .phase_static, .limit_source = .caller, .storage = .{ .covered = &.{ .{ .id = "one_exact_byte_offset_per_logical_source_line_for_one_file", .lifetime = .steady, .detail = "one exact byte offset per logical source line for one file", }, }, .excluded = &.{ "borrowed source file bytes", "parser tree and AST scratch storage", "retained graph nodes edges names and metadata", }, }, .capacity = .{ .inputs = &.{ alloc_phase.capacity.bindInput(Limits, "source", "source"), }, .type_selectors = &.{ alloc_phase.capacity.bindType(usize, "usize"), }, .nodes = &.{ .{ .collection = .{ .byte_count = .{ .input = 0, .byte = '\n', } } }, .{ .constant = 1 }, .{ .add = .{ .left = 0, .right = 1 } }, .{ .scale = .{ .node = 2, .coefficient = .{ .size_of_concrete_type = 0 }, } }, }, .assertions = &.{.{ .scope = .closure_total, .measure = .retained, .relation = .exact, .expression = 3, }}, }, .overload = .{ .kind = .reject_before_seal, .detail = "checked line and byte counts plus one exact acquisition reject overflow or OOM before activation", }, .risks = .{ .transitive = .{ .status = .witnessed, .detail = "line fill and all steady lookup operations remain allocation-free under a sealed allocator", }, .foreign = .{ .status = .excluded, .detail = "the index is process-local caller-owned memory with no operating-system or callback edge", }, }, .obligations = &.{ .{ .key = "smg_source_line_index_capacity_capacity_model", .role = .capacity_model }, .{ .key = "smg_source_line_index_capacity_overload", .role = .overload }, .{ .key = "smg_source_line_index_oom", .role = .overload }, .{ .key = "smg_source_line_index_sealed_transitive_risk", .role = .transitive_risk }, .{ .key = "smg_source_line_index_sealed_foreign_risk", .role = .foreign_risk }, .{ .key = "smg_source_line_index_integration", .role = .custom }, }, }, .bindings = .{ .owner = @This(), .seal = .{ .family = alloc_phase.capacity.selector(@This().activate), .premise = .{ .class = .checked_semantic_fact, .authority = .checker, }, }, .teardown = .{ .family = alloc_phase.capacity.selector(@This().deinit), .premise = .{ .class = .checked_semantic_fact, .authority = .checker, }, }, }, }; phase: alloc_phase.capacity.Phase, capacity: Capacity, source: []const u8, starts: []usize, pub fn init(allocator: std.mem.Allocator, limits: Limits) InitError!SourceLines { const capacity = try Capacity.derive(limits); return .{ .phase = .initialization, .capacity = capacity, .source = limits.source, .starts = try allocator.alloc(usize, capacity.starts), }; } pub fn fill(self: *SourceLines) void { std.debug.assert(self.phase == .initialization); self.starts[0] = 0; var filled: usize = 1; for (self.source, 0..) |byte, index| { if (byte != '\n') continue; self.starts[filled] = index + 1; filled += 1; } std.debug.assert(filled == self.starts.len); } pub fn activate(self: *SourceLines) void { std.debug.assert(self.phase == .initialization); std.debug.assert(self.starts.len == self.capacity.starts); self.phase = .steady; } pub fn deinit(self: *SourceLines, allocator: std.mem.Allocator) void { std.debug.assert(self.phase != .teardown); self.phase = .teardown; allocator.free(self.starts); self.* = undefined; }};Source: tools/smg/src/root.zig:116
zig
pub const SourceLineIndex = @import("lines.zig").SourceLines;Complete caller list for SourceLineIndex.activate
8 direct callers.
tools.smg.src.lines.test_source_line_index_fills_and_serves_byte_mappings_while_sealed[function] — test; no exact target attools/smg/src/lines.zig:338in nearest public ownertiny.smg.linestools.smg.src.lines.test_source_line_index_initialization_cleans_allocation_failure_and_retries[function] — test; no exact target attools/smg/src/lines.zig:313in nearest public ownertiny.smg.linestools.smg.src.lines.test_source_lines_map_line_numbers_to_byte_offsets[function] — test; no exact target attools/smg/src/lines.zig:197in nearest public ownertiny.smg.linestools.smg.src.scan.pipeline.scan.scanFileUnit[function] — private; no exact target attools/smg/src/scan/pipeline/scan.zig:1502in nearest public ownertools.smg.src.scan.pipeline.scantools.smg.src.scan.pipeline.scan.test_zig_native_and_tree_alias_targets_preserve_imported_member_owners[function] — test; no exact target attools/smg/src/scan/pipeline/scan.zig:4487in nearest public ownertools.smg.src.scan.pipeline.scantools.smg.src.scan.pipeline.scan.test_zig_tree_scan_exposes_declared_types_and_mutable_storage_semantics[function] — test; no exact target attools/smg/src/scan/pipeline/scan.zig:4737in nearest public ownertools.smg.src.scan.pipeline.scantools.smg.src.span.test_trimmed_span_removes_surrounding_whitespace[function] — test; no exact target attools/smg/src/span.zig:19in nearest public ownertiny.smg.spantools.smg.src.zig.test_ast_nodes_map_to_source_lines[function] — test; no exact target attools/smg/src/zig.zig:166in nearest public ownertiny.smg.zig
Complete caller list for SourceLineIndex.deinit
10 direct callers.
tools.smg.src.lines.checkSourceLineIndexInitAllocationFailures[function] — private; no exact target attools/smg/src/lines.zig:308in nearest public ownertiny.smg.linestools.smg.src.lines.test_source_line_index_capacity_matches_an_independent_newline_model[function] — test; no exact target attools/smg/src/lines.zig:211in nearest public ownertiny.smg.linestools.smg.src.lines.test_source_line_index_fills_and_serves_byte_mappings_while_sealed[function] — test; no exact target attools/smg/src/lines.zig:338in nearest public ownertiny.smg.linestools.smg.src.lines.test_source_line_index_initialization_cleans_allocation_failure_and_retries[function] — test; no exact target attools/smg/src/lines.zig:313in nearest public ownertiny.smg.linestools.smg.src.lines.test_source_lines_map_line_numbers_to_byte_offsets[function] — test; no exact target attools/smg/src/lines.zig:197in nearest public ownertiny.smg.linestools.smg.src.scan.pipeline.scan.scanFileUnit[function] — private; no exact target attools/smg/src/scan/pipeline/scan.zig:1502in nearest public ownertools.smg.src.scan.pipeline.scantools.smg.src.scan.pipeline.scan.test_zig_native_and_tree_alias_targets_preserve_imported_member_owners[function] — test; no exact target attools/smg/src/scan/pipeline/scan.zig:4487in nearest public ownertools.smg.src.scan.pipeline.scantools.smg.src.scan.pipeline.scan.test_zig_tree_scan_exposes_declared_types_and_mutable_storage_semantics[function] — test; no exact target attools/smg/src/scan/pipeline/scan.zig:4737in nearest public ownertools.smg.src.scan.pipeline.scantools.smg.src.span.test_trimmed_span_removes_surrounding_whitespace[function] — test; no exact target attools/smg/src/span.zig:19in nearest public ownertiny.smg.spantools.smg.src.zig.test_ast_nodes_map_to_source_lines[function] — test; no exact target attools/smg/src/zig.zig:166in nearest public ownertiny.smg.zig
Complete caller list for SourceLineIndex.fill
8 direct callers.
tools.smg.src.lines.test_source_line_index_fills_and_serves_byte_mappings_while_sealed[function] — test; no exact target attools/smg/src/lines.zig:338in nearest public ownertiny.smg.linestools.smg.src.lines.test_source_line_index_initialization_cleans_allocation_failure_and_retries[function] — test; no exact target attools/smg/src/lines.zig:313in nearest public ownertiny.smg.linestools.smg.src.lines.test_source_lines_map_line_numbers_to_byte_offsets[function] — test; no exact target attools/smg/src/lines.zig:197in nearest public ownertiny.smg.linestools.smg.src.scan.pipeline.scan.scanFileUnit[function] — private; no exact target attools/smg/src/scan/pipeline/scan.zig:1502in nearest public ownertools.smg.src.scan.pipeline.scantools.smg.src.scan.pipeline.scan.test_zig_native_and_tree_alias_targets_preserve_imported_member_owners[function] — test; no exact target attools/smg/src/scan/pipeline/scan.zig:4487in nearest public ownertools.smg.src.scan.pipeline.scantools.smg.src.scan.pipeline.scan.test_zig_tree_scan_exposes_declared_types_and_mutable_storage_semantics[function] — test; no exact target attools/smg/src/scan/pipeline/scan.zig:4737in nearest public ownertools.smg.src.scan.pipeline.scantools.smg.src.span.test_trimmed_span_removes_surrounding_whitespace[function] — test; no exact target attools/smg/src/span.zig:19in nearest public ownertiny.smg.spantools.smg.src.zig.test_ast_nodes_map_to_source_lines[function] — test; no exact target attools/smg/src/zig.zig:166in nearest public ownertiny.smg.zig
Complete caller list for SourceLineIndex.init
10 direct callers.
tools.smg.src.lines.checkSourceLineIndexInitAllocationFailures[function] — private; no exact target attools/smg/src/lines.zig:308in nearest public ownertiny.smg.linestools.smg.src.lines.test_source_line_index_capacity_matches_an_independent_newline_model[function] — test; no exact target attools/smg/src/lines.zig:211in nearest public ownertiny.smg.linestools.smg.src.lines.test_source_line_index_fills_and_serves_byte_mappings_while_sealed[function] — test; no exact target attools/smg/src/lines.zig:338in nearest public ownertiny.smg.linestools.smg.src.lines.test_source_line_index_initialization_cleans_allocation_failure_and_retries[function] — test; no exact target attools/smg/src/lines.zig:313in nearest public ownertiny.smg.linestools.smg.src.lines.test_source_lines_map_line_numbers_to_byte_offsets[function] — test; no exact target attools/smg/src/lines.zig:197in nearest public ownertiny.smg.linestools.smg.src.scan.pipeline.scan.scanFileUnit[function] — private; no exact target attools/smg/src/scan/pipeline/scan.zig:1502in nearest public ownertools.smg.src.scan.pipeline.scantools.smg.src.scan.pipeline.scan.test_zig_native_and_tree_alias_targets_preserve_imported_member_owners[function] — test; no exact target attools/smg/src/scan/pipeline/scan.zig:4487in nearest public ownertools.smg.src.scan.pipeline.scantools.smg.src.scan.pipeline.scan.test_zig_tree_scan_exposes_declared_types_and_mutable_storage_semantics[function] — test; no exact target attools/smg/src/scan/pipeline/scan.zig:4737in nearest public ownertools.smg.src.scan.pipeline.scantools.smg.src.span.test_trimmed_span_removes_surrounding_whitespace[function] — test; no exact target attools/smg/src/span.zig:19in nearest public ownertiny.smg.spantools.smg.src.zig.test_ast_nodes_map_to_source_lines[function] — test; no exact target attools/smg/src/zig.zig:166in nearest public ownertiny.smg.zig
Audit
| Definitions | 10 |
|---|---|
| Public names | 20 |
| Members | 7 |
| Version | 26.7.0 |
| Revision | daab053ee433 |