diff options
| author | Robin Voetter <robin@voetter.nl> | 2022-11-26 01:05:37 +0100 |
|---|---|---|
| committer | Robin Voetter <robin@voetter.nl> | 2023-04-09 01:51:48 +0200 |
| commit | 5826a8a0640d79de83be131434ec91315e75087b (patch) | |
| tree | 662d00213cd9b993e2a56dab7675db725d49ace3 /src/codegen/spirv/Module.zig | |
| parent | a60308f87c658a210e9b3bd619e908368db6f24e (diff) | |
| download | zig-5826a8a0640d79de83be131434ec91315e75087b.tar.gz zig-5826a8a0640d79de83be131434ec91315e75087b.zip | |
spirv: make Type.Ref stronger
Making Type.Ref an unbounded enum rather than a simple integer
ensures that we don't accidently confuse this token for another type.
Diffstat (limited to 'src/codegen/spirv/Module.zig')
| -rw-r--r-- | src/codegen/spirv/Module.zig | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig index 3562e87be4..2b62bcaf0e 100644 --- a/src/codegen/spirv/Module.zig +++ b/src/codegen/spirv/Module.zig @@ -216,7 +216,7 @@ pub fn resolveType(self: *Module, ty: Type) !Type.Ref { result.value_ptr.* = try self.emitType(ty); } - return result.index; + return @intToEnum(Type.Ref, result.index); } pub fn resolveTypeId(self: *Module, ty: Type) !IdRef { @@ -226,12 +226,12 @@ pub fn resolveTypeId(self: *Module, ty: Type) !IdRef { /// Get the result-id of a particular type, by reference. Asserts type_ref is valid. pub fn typeResultId(self: Module, type_ref: Type.Ref) IdResultType { - return self.type_cache.values()[type_ref]; + return self.type_cache.values()[@enumToInt(type_ref)]; } /// Get the result-id of a particular type as IdRef, by Type.Ref. Asserts type_ref is valid. pub fn typeRefId(self: Module, type_ref: Type.Ref) IdRef { - return self.type_cache.values()[type_ref].toRef(); + return self.type_cache.values()[@enumToInt(type_ref)].toRef(); } /// Unconditionally emit a spir-v type into the appropriate section. |
