diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CHANGELOG.md | 6 | ||||
| -rw-r--r-- | src/walk.zig | 24 |
2 files changed, 24 insertions, 6 deletions
diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md index f367774e..c1a78828 100644 --- a/src/CHANGELOG.md +++ b/src/CHANGELOG.md @@ -41,6 +41,12 @@ A column resizes by its box, left of its tag; a pane by its own box, or in a window by the rule above it. +- An edit to the core recompiles it about 1 s sooner again (`core-test`, + 6 % fewer of the compiler's instructions, 3 MB less code in a Debug + test): a load's note on a field (another build's dump) is written from + the type's and the field's names at run time, where every type and + field had its own copy of the code that writes one. + - An edit to the core recompiles it about 3 s sooner (`core-test`, 13 s to 10 s): the build keeps each grammar's highlight patterns that pardes colours once, where every compile of every program that takes the core 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) { |
