adding opcodes and results

This commit is contained in:
2025-12-27 00:46:40 +01:00
parent 49f0219900
commit 3283ed42a8
7 changed files with 336 additions and 62 deletions

View File

@@ -1,3 +1,4 @@
const std = @import("std");
const spv = @import("spv.zig");
const SpvWord = spv.SpvWord;
@@ -20,6 +21,12 @@ pub fn next(self: *Self) ?SpvWord {
return word;
}
pub fn nextAs(self: *Self, comptime E: type) ?E {
const word = self.peek() orelse return null;
self.index += 1;
return std.enums.fromInt(E, word);
}
pub fn peek(self: *const Self) ?SpvWord {
return if (self.index >= self.buffer.len) null else self.buffer[self.index];
}