diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 02:22:35 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 07d1e5066ef38c99cb112cb709fb719e3470bd0d (patch) | |
| tree | 8e4ebb10da2e2b97037baf4f07a4699b7862a149 /src/walk.zig | |
| parent | b3d32656413734952bc918c2d4cfd12fede6c214 (diff) | |
| download | pardes-07d1e5066ef38c99cb112cb709fb719e3470bd0d.tar.gz pardes-07d1e5066ef38c99cb112cb709fb719e3470bd0d.zip | |
walk: a load's note on a field is written from the names at run time: Load's and Get's three notes on a field (its kind changed, its default taken or left as it was; not in the dump) passed .{ @typeName(T), field }, a tuple of comptime strings, so `note` and std's print under it were compiled once a type, field and message (2,506 instances of note, 2,225 of Writer.print); noteField takes the two names as run-time strings and is one instance a message; the notes' text is the same, byte for byte; core-test's forced full recompile (Debug, one filter) 120.12e9 to 112.95e9 instructions (-6.0 %), generic instances 19,383 to 14,799, the Debug test's text 85.84 MB to 82.82 MB; a session's byte dump, its image and a closed pane's save are the same bytes before and after (but the clock's), each build loads the other's with no note and the same digest, wire.semantics and the tape's shape unchanged; the changelog says so
Diffstat (limited to 'src/walk.zig')
| -rw-r--r-- | src/walk.zig | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/walk.zig b/src/walk.zig index 3641d327..ffa97af2 100644 --- a/src/walk.zig +++ b/src/walk.zig @@ -1135,6 +1135,13 @@ pub fn Load(comptime roots: []const type) type { l.notes.print(l.own, fmt ++ "\n", args) catch {}; } + /// A note on a type's field, its names given as run-time strings: + /// one instance of `note` (and of std's `print`) a message, where + /// a tuple of the comptime names made one a type, field and message. + fn noteField(l: *Self, comptime what: []const u8, type_name: []const u8, field: []const u8) void { + l.note("{s}.{s}: " ++ what, .{ type_name, field }); + } + fn root(l: *Self) DecodeError!u32 { const ty = try l.scalar(u32); if (ty >= l.src.len) return error.BadDump; @@ -1441,9 +1448,9 @@ pub fn Load(comptime roots: []const type) type { const attr = comptime @typeInfo(T).@"struct".field_attrs[std.meta.fieldIndex(T, field).?]; if (comptime attr.default_value_ptr) |dp| { @field(out, field) = @as(*const @FieldType(T, field), @ptrCast(@alignCast(dp))).*; - l.note("{s}.{s}: its kind changed; its default taken", .{ @typeName(T), field }); + l.noteField("its kind changed; its default taken", @typeName(T), field); } else if (existing) { - l.note("{s}.{s}: its kind changed; left as it was", .{ @typeName(T), field }); + l.noteField("its kind changed; left as it was", @typeName(T), field); } else failed = true; }; }; @@ -1454,7 +1461,7 @@ pub fn Load(comptime roots: []const type) type { const attr = comptime @typeInfo(T).@"struct".field_attrs[std.meta.fieldIndex(T, field).?]; if (comptime attr.default_value_ptr == null) { if (!existing) { - l.note("{s}.{s}: not in the dump", .{ @typeName(T), field }); + l.noteField("not in the dump", @typeName(T), field); failed = true; } } @@ -1854,6 +1861,11 @@ pub const Get = struct { l.notes.print(l.own, fmt ++ "\n", args) catch {}; } + /// A note on a type's field, its names given at run time (Load's). + fn noteField(l: *Get, comptime what: []const u8, type_name: []const u8, field: []const u8) void { + l.note("{s}.{s}: " ++ what, .{ type_name, field }); + } + /// The value at `c`, made: what it points at is `gpa`'s. pub fn get(l: *Get, comptime T: type, c: Cursor) Error!T { var out: T = undefined; @@ -2270,9 +2282,9 @@ pub const Get = struct { const attr = comptime @typeInfo(T).@"struct".field_attrs[std.meta.fieldIndex(T, field).?]; if (comptime attr.default_value_ptr) |dp| { @field(out, field) = @as(*const @FieldType(T, field), @ptrCast(@alignCast(dp))).*; - l.note("{s}.{s}: its kind changed; its default taken", .{ @typeName(T), field }); + l.noteField("its kind changed; its default taken", @typeName(T), field); } else if (existing) { - l.note("{s}.{s}: its kind changed; left as it was", .{ @typeName(T), field }); + l.noteField("its kind changed; left as it was", @typeName(T), field); } else failed = true; }; }; @@ -2284,7 +2296,7 @@ pub const Get = struct { const attr = comptime @typeInfo(T).@"struct".field_attrs[std.meta.fieldIndex(T, field).?]; if (comptime attr.default_value_ptr == null and kindOf(Canon(F)) != .void) { if (!existing) { - l.note("{s}.{s}: not in the dump", .{ @typeName(T), field }); + l.noteField("not in the dump", @typeName(T), field); failed = true; } } else if (comptime @typeInfo(F) == .optional and defaultIsNull(T, field)) if (existing) { |
