Function addGlobalAssumeCapacity [src]

Prototype

pub fn addGlobalAssumeCapacity(self: *Builder, name: StrtabString, global: Global) Global.Index

Parameters

self: *Buildername: StrtabStringglobal: Global

Source

pub fn addGlobalAssumeCapacity(self: *Builder, name: StrtabString, global: Global) Global.Index { _ = self.ptrTypeAssumeCapacity(global.addr_space); var id = name; if (name == .empty) { id = self.next_unnamed_global; assert(id != self.next_replaced_global); self.next_unnamed_global = @enumFromInt(@intFromEnum(id) + 1); } while (true) { const global_gop = self.globals.getOrPutAssumeCapacity(id); if (!global_gop.found_existing) { global_gop.value_ptr.* = global; const global_index: Global.Index = @enumFromInt(global_gop.index); global_index.updateDsoLocal(self); return global_index; } const unique_gop = self.next_unique_global_id.getOrPutAssumeCapacity(name); if (!unique_gop.found_existing) unique_gop.value_ptr.* = 2; id = self.strtabStringFmtAssumeCapacity("{s}.{d}", .{ name.slice(self).?, unique_gop.value_ptr.* }); unique_gop.value_ptr.* += 1; } }