tiny.smg.scan.source_metadata
Defined in scan.
Exact source evidence shared by language scanners.
API (1)
Actions
Public operations.
Source
Source: tools/smg/src/scan/root.zig:12
zig
pub const source_metadata = @import("source.zig");Source: tools/smg/src/scan/source.zig
zig
//! Exact source evidence shared by language scanners.const std = @import("std");const smg = @import("../root.zig");const api = smg.api;const model = smg.model;pub fn spanMetadata( allocator: std.mem.Allocator, base: []const model.Pair, source: []const u8, span: api.SourceSpan,) ![]const model.Pair { std.debug.assert(span.start_byte < span.end_byte); std.debug.assert(span.end_byte <= source.len); const updates = try allocator.alloc(model.Pair, 3); updates[0] = try integerPair(allocator, api.source_start_byte_key, span.start_byte); updates[1] = try integerPair(allocator, api.source_end_byte_key, span.end_byte); const digest = api.sourceDigest(source[span.start_byte..span.end_byte]); const encoded = std.fmt.bytesToHex(digest, .lower); updates[2] = .{ .key = try allocator.dupe(u8, api.source_hash_key), .value = try allocator.dupe(u8, &encoded), }; return try model.mergePairs(allocator, base, updates);}fn integerPair( allocator: std.mem.Allocator, key: []const u8, value: anytype,) !model.Pair { return .{ .key = try allocator.dupe(u8, key), .value = try std.fmt.allocPrint(allocator, "{d}", .{value}), };}Audit
| Definitions | 2 |
|---|---|
| Public names | 2 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |