summaryrefslogtreecommitdiff
path: root/core/walk.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/walk.zig')
-rw-r--r--core/walk.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/walk.zig b/core/walk.zig
index 9b760144..d870052d 100644
--- a/core/walk.zig
+++ b/core/walk.zig
@@ -711,6 +711,22 @@ fn graph(comptime roots: []const type) []const type {
}
}
+/// The types the walk of `roots` reaches that walk themselves by hand (a
+/// `digest` or a `dumpWrite` of their own): the ones whose digest can take
+/// what their dump does not carry, which the one walk holds for the rest.
+pub fn handWalked(comptime roots: []const type) []const type {
+ comptime {
+ var out: []const type = &.{};
+ for (graph(roots)) |T| switch (@typeInfo(T)) {
+ .@"struct", .@"union" => if (@hasDecl(T, "dumpWrite") or (@hasDecl(T, "digest") and @TypeOf(T.digest) == fn (*const T, *Hasher) void)) {
+ out = out ++ .{T};
+ },
+ else => {},
+ };
+ return out;
+ }
+}
+
fn indexIn(comptime types: []const type, comptime T: type) u32 {
comptime {
@setEvalBranchQuota(100_000_000);