adding types opcodes
This commit is contained in:
@@ -6,20 +6,36 @@ const SpvByte = spv.SpvByte;
|
||||
const SpvWord = spv.SpvWord;
|
||||
const SpvBool = spv.SpvBool;
|
||||
|
||||
const RType = enum {
|
||||
const Type = enum {
|
||||
None,
|
||||
String,
|
||||
Extension,
|
||||
Function_type,
|
||||
FunctionType,
|
||||
Type,
|
||||
Variable,
|
||||
Constant,
|
||||
Function,
|
||||
Access_chain,
|
||||
Function_parameter,
|
||||
AccessChain,
|
||||
FunctionParameter,
|
||||
Label,
|
||||
};
|
||||
|
||||
const ValueType = enum {
|
||||
Void,
|
||||
Bool,
|
||||
Int,
|
||||
Float,
|
||||
Vector,
|
||||
Matrix,
|
||||
Array,
|
||||
RuntimeArray,
|
||||
Structure,
|
||||
Image,
|
||||
Sampler,
|
||||
SampledImage,
|
||||
Pointer,
|
||||
};
|
||||
|
||||
const ImageInfo = struct {
|
||||
dim: spv.SpvDim,
|
||||
depth: SpvByte,
|
||||
@@ -33,16 +49,14 @@ const ImageInfo = struct {
|
||||
const Decoration = struct {
|
||||
rtype: spv.SpvDecoration,
|
||||
literal_1: SpvWord,
|
||||
literal_2: SpvWord,
|
||||
literal_2: ?SpvWord,
|
||||
index: SpvWord,
|
||||
};
|
||||
|
||||
const Self = @This();
|
||||
|
||||
name: ?[]const u8,
|
||||
ptr: SpvWord,
|
||||
|
||||
storage_class: spv.SpvStorageClass,
|
||||
parent: ?*const Self,
|
||||
|
||||
member_names: std.ArrayList([]const u8),
|
||||
@@ -50,20 +64,66 @@ members: std.ArrayList(spv.SpvMember),
|
||||
|
||||
decorations: std.ArrayList(Decoration),
|
||||
|
||||
/// Only for functions
|
||||
return_type: SpvWord,
|
||||
|
||||
rtype: RType,
|
||||
res_type: Type,
|
||||
type_data: union(Type) {
|
||||
None: struct {},
|
||||
String: []const u8,
|
||||
Extension: struct {},
|
||||
FunctionType: struct {
|
||||
return_type: SpvWord,
|
||||
},
|
||||
Type: struct {
|
||||
value_type: ValueType,
|
||||
data: union(ValueType) {
|
||||
Void: struct {},
|
||||
Bool: struct {},
|
||||
Int: struct {
|
||||
bit_length: SpvWord,
|
||||
is_signed: bool,
|
||||
},
|
||||
Float: struct {
|
||||
bit_length: SpvWord,
|
||||
},
|
||||
Vector: struct {
|
||||
components_type: ValueType,
|
||||
},
|
||||
Matrix: struct {
|
||||
column_type: ValueType,
|
||||
},
|
||||
Array: struct {},
|
||||
RuntimeArray: struct {},
|
||||
Structure: struct {},
|
||||
Image: struct {},
|
||||
Sampler: struct {},
|
||||
SampledImage: struct {},
|
||||
Pointer: struct {
|
||||
storage_class: spv.SpvStorageClass,
|
||||
},
|
||||
},
|
||||
member_count: SpvWord = 0,
|
||||
id: SpvWord = 0,
|
||||
},
|
||||
Variable: struct {},
|
||||
Constant: struct {},
|
||||
Function: struct {
|
||||
/// Allocated array
|
||||
params: []SpvWord,
|
||||
},
|
||||
AccessChain: struct {},
|
||||
FunctionParameter: struct {},
|
||||
Label: struct {},
|
||||
},
|
||||
|
||||
pub fn init() Self {
|
||||
return std.mem.zeroInit(Self, .{
|
||||
return .{
|
||||
.name = null,
|
||||
.parent = null,
|
||||
.member_names = std.ArrayList([]const u8).empty,
|
||||
.members = std.ArrayList(spv.SpvMember).empty,
|
||||
.decorations = std.ArrayList(Decoration).empty,
|
||||
.rtype = RType.None,
|
||||
});
|
||||
.member_names = .empty,
|
||||
.members = .empty,
|
||||
.decorations = .empty,
|
||||
.res_type = .None,
|
||||
.type_data = undefined,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
|
||||
@@ -73,6 +133,11 @@ pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
|
||||
for (self.member_names.items) |name| {
|
||||
allocator.free(name);
|
||||
}
|
||||
// FIXME
|
||||
//switch (self.type_data) {
|
||||
// .Function => |data| allocator.free(data.params),
|
||||
// else => {},
|
||||
//}
|
||||
self.member_names.deinit(allocator);
|
||||
self.members.deinit(allocator);
|
||||
self.decorations.deinit(allocator);
|
||||
|
||||
Reference in New Issue
Block a user