mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Module: add support for multiple global asm blocks per decl
Closes #16076
This commit is contained in:
parent
e6e8cacab9
commit
8fcc28d302
2 changed files with 11 additions and 6 deletions
|
|
@ -6636,12 +6636,14 @@ fn markDeclIndexAlive(mod: *Module, decl_index: Decl.Index) Allocator.Error!void
|
|||
}
|
||||
|
||||
pub fn addGlobalAssembly(mod: *Module, decl_index: Decl.Index, source: []const u8) !void {
|
||||
try mod.global_assembly.ensureUnusedCapacity(mod.gpa, 1);
|
||||
|
||||
const duped_source = try mod.gpa.dupe(u8, source);
|
||||
errdefer mod.gpa.free(duped_source);
|
||||
|
||||
mod.global_assembly.putAssumeCapacityNoClobber(decl_index, duped_source);
|
||||
const gop = try mod.global_assembly.getOrPut(mod.gpa, decl_index);
|
||||
if (gop.found_existing) {
|
||||
const new_value = try std.fmt.allocPrint(mod.gpa, "{s}\n{s}", .{ gop.value_ptr.*, source });
|
||||
mod.gpa.free(gop.value_ptr.*);
|
||||
gop.value_ptr.* = new_value;
|
||||
} else {
|
||||
gop.value_ptr.* = try mod.gpa.dupe(u8, source);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn wantDllExports(mod: Module) bool {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ comptime {
|
|||
{
|
||||
asm (
|
||||
\\.globl this_is_my_alias;
|
||||
);
|
||||
// test multiple asm per comptime block
|
||||
asm (
|
||||
\\.type this_is_my_alias, @function;
|
||||
\\.set this_is_my_alias, derp;
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue