adding util to runtime api
Test / build (push) Failing after 31s
Build / build (push) Successful in 48s

This commit is contained in:
2026-06-05 17:48:21 +02:00
parent ee5a400010
commit ad87703ea8
4 changed files with 166 additions and 1 deletions
+16 -1
View File
@@ -12,7 +12,9 @@ const SpvWord = spv.SpvWord;
const SpvBool = spv.SpvBool;
const Module = @import("Module.zig");
const PrimitiveType = @import("Value.zig").PrimitiveType;
const Result = @import("Result.zig");
const Value = @import("Value.zig").Value;
const WordIterator = @import("WordIterator.zig");
const Self = @This();
@@ -195,6 +197,19 @@ pub fn getResultByLocationComponent(self: *const Self, location: SpvWord, compon
return RuntimeError.NotFound;
}
pub fn getResultPrimitiveType(self: *const Self, result: SpvWord) RuntimeError!PrimitiveType {
if (result >= self.results.len)
return RuntimeError.OutOfBounds;
return (try self.results[result].getConstValue()).resolvePrimitiveType();
}
pub fn resultIsInteger(self: *const Self, result: SpvWord) bool {
return switch (self.getResultPrimitiveType(result) catch return false) {
.SInt, .UInt => true,
else => false,
};
}
pub fn dumpResultsTable(self: *Self, allocator: std.mem.Allocator, writer: *std.Io.Writer) RuntimeError!void {
const dump = pretty.dump(allocator, self.results, .{
.tab_size = 4,
@@ -414,7 +429,7 @@ fn resolveInputLocationTarget(self: *const Self, location: SpvWord) RuntimeError
return RuntimeError.NotFound;
}
fn getInputLocationTargetValue(self: *const Self, target: InputLocationTarget) RuntimeError!*@import("Value.zig").Value {
fn getInputLocationTargetValue(self: *const Self, target: InputLocationTarget) RuntimeError!*Value {
const value = switch ((try self.results[target.result].getVariant()).*) {
.Variable => |*v| &v.value,
.AccessChain => |*a| &a.value,