spirv: put global var initializers in functions

This commit is contained in:
Robin Voetter
2023-09-16 13:14:38 +02:00
committed by Andrew Kelley
parent 240f9d740d
commit b30cd67987
2 changed files with 240 additions and 114 deletions

View File

@@ -174,6 +174,9 @@ globals: struct {
section: Section = .{},
} = .{},
/// The function IDs of global variable initializers
initializers: std.ArrayListUnmanaged(IdRef) = .{},
pub fn init(gpa: Allocator, arena: Allocator) Module {
return .{
.gpa = gpa,
@@ -202,6 +205,8 @@ pub fn deinit(self: *Module) void {
self.globals.globals.deinit(self.gpa);
self.globals.section.deinit(self.gpa);
self.initializers.deinit(self.gpa);
self.* = undefined;
}