Skip to documentation
SLOP

tiny.smg.SourceLineIndex

Reference 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.

No direct callersNo direct callslinesSourceLines
Static calls · unresolved targets: unknown · external targets: unknown.

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;
Called byCallsSourceLineIndexinittest; no linktools.smg.src.linestest: source line index capacity matc...private; no linktools.smg.src.lineslogicalLineCountprivate; no linktools.smg.src.linessourceLineBytesSourceLineIndex.Capacityderive
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest; no linktools.smg.src.linestest: source line index fills and ser...test; no linktools.smg.src.linestest: source line index initializatio...test; no linktools.smg.src.linestest: source lines map line numbers t...private; no linktools.smg.src.scan.pipeline.scanscanFileUnittest; no linktools.smg.src.scan.pipeline.scantest: zig native and tree alias targe...+3 moreSourceLineIndexactivate
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate; no linktools.smg.src.linescheckSourceLineIndexInitAllocationFai...test; no linktools.smg.src.linestest: source line index capacity matc...test; no linktools.smg.src.linestest: source line index fills and ser...test; no linktools.smg.src.linestest: source line index initializatio...test; no linktools.smg.src.linestest: source lines map line numbers t...+5 moreSourceLineIndexdeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callstest; no linktools.smg.src.linestest: source line index fills and ser...test; no linktools.smg.src.linestest: source line index initializatio...test; no linktools.smg.src.linestest: source lines map line numbers t...private; no linktools.smg.src.scan.pipeline.scanscanFileUnittest; no linktools.smg.src.scan.pipeline.scantest: zig native and tree alias targe...+3 moreSourceLineIndexfill
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate; no linktools.smg.src.linescheckSourceLineIndexInitAllocationFai...test; no linktools.smg.src.linestest: source line index capacity matc...test; no linktools.smg.src.linestest: source line index fills and ser...test; no linktools.smg.src.linestest: source line index initializatio...test; no linktools.smg.src.linestest: source lines map line numbers t...+5 moreSourceLineIndex.CapacityderiveSourceLineIndexinit
Static calls · unresolved targets: 0 · external targets: 1.

Complete caller list for SourceLineIndex.activate

8 direct callers.

Complete caller list for SourceLineIndex.deinit

10 direct callers.

Complete caller list for SourceLineIndex.fill

8 direct callers.

Complete caller list for SourceLineIndex.init

10 direct callers.

Audit

Definitions10
Public names20
Members7
Version26.7.0
Revisiondaab053ee433