@@ -6,20 +6,36 @@ const SpvByte = spv.SpvByte;
66const SpvWord = spv .SpvWord ;
77const SpvBool = spv .SpvBool ;
88
9- const RType = enum {
9+ const Type = enum {
1010 None ,
1111 String ,
1212 Extension ,
13- Function_type ,
13+ FunctionType ,
1414 Type ,
1515 Variable ,
1616 Constant ,
1717 Function ,
18- Access_chain ,
19- Function_parameter ,
18+ AccessChain ,
19+ FunctionParameter ,
2020 Label ,
2121};
2222
23+ const ValueType = enum {
24+ Void ,
25+ Bool ,
26+ Int ,
27+ Float ,
28+ Vector ,
29+ Matrix ,
30+ Array ,
31+ RuntimeArray ,
32+ Structure ,
33+ Image ,
34+ Sampler ,
35+ SampledImage ,
36+ Pointer ,
37+ };
38+
2339const ImageInfo = struct {
2440 dim : spv.SpvDim ,
2541 depth : SpvByte ,
@@ -33,37 +49,81 @@ const ImageInfo = struct {
3349const Decoration = struct {
3450 rtype : spv.SpvDecoration ,
3551 literal_1 : SpvWord ,
36- literal_2 : SpvWord ,
52+ literal_2 : ? SpvWord ,
3753 index : SpvWord ,
3854};
3955
4056const Self = @This ();
4157
4258name : ? []const u8 ,
43- ptr : SpvWord ,
4459
45- storage_class : spv.SpvStorageClass ,
4660parent : ? * const Self ,
4761
4862member_names : std .ArrayList ([]const u8 ),
4963members : std .ArrayList (spv .SpvMember ),
5064
5165decorations : std .ArrayList (Decoration ),
5266
53- /// Only for functions
54- return_type : SpvWord ,
55-
56- rtype : RType ,
67+ res_type : Type ,
68+ type_data : union (Type ) {
69+ None : struct {},
70+ String : []const u8 ,
71+ Extension : struct {},
72+ FunctionType : struct {
73+ return_type : SpvWord ,
74+ },
75+ Type : struct {
76+ value_type : ValueType ,
77+ data : union (ValueType ) {
78+ Void : struct {},
79+ Bool : struct {},
80+ Int : struct {
81+ bit_length : SpvWord ,
82+ is_signed : bool ,
83+ },
84+ Float : struct {
85+ bit_length : SpvWord ,
86+ },
87+ Vector : struct {
88+ components_type : ValueType ,
89+ },
90+ Matrix : struct {
91+ column_type : ValueType ,
92+ },
93+ Array : struct {},
94+ RuntimeArray : struct {},
95+ Structure : struct {},
96+ Image : struct {},
97+ Sampler : struct {},
98+ SampledImage : struct {},
99+ Pointer : struct {
100+ storage_class : spv.SpvStorageClass ,
101+ },
102+ },
103+ member_count : SpvWord = 0 ,
104+ id : SpvWord = 0 ,
105+ },
106+ Variable : struct {},
107+ Constant : struct {},
108+ Function : struct {
109+ /// Allocated array
110+ params : []SpvWord ,
111+ },
112+ AccessChain : struct {},
113+ FunctionParameter : struct {},
114+ Label : struct {},
115+ },
57116
58117pub fn init () Self {
59- return std . mem . zeroInit ( Self , .{
118+ return .{
60119 .name = null ,
61120 .parent = null ,
62- .member_names = std .ArrayList ([]const u8 ).empty ,
63- .members = std .ArrayList (spv .SpvMember ).empty ,
64- .decorations = std .ArrayList (Decoration ).empty ,
65- .rtype = RType .None ,
66- });
121+ .member_names = .empty ,
122+ .members = .empty ,
123+ .decorations = .empty ,
124+ .res_type = .None ,
125+ .type_data = undefined ,
126+ };
67127}
68128
69129pub fn deinit (self : * Self , allocator : std.mem.Allocator ) void {
@@ -73,6 +133,11 @@ pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
73133 for (self .member_names .items ) | name | {
74134 allocator .free (name );
75135 }
136+ // FIXME
137+ //switch (self.type_data) {
138+ // .Function => |data| allocator.free(data.params),
139+ // else => {},
140+ //}
76141 self .member_names .deinit (allocator );
77142 self .members .deinit (allocator );
78143 self .decorations .deinit (allocator );
0 commit comments