Files

22 lines
720 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Expect retcode = 0
// mangling:2ir(hir2ir)阶段把非根模块的函数名改编为模块限定名,避免跨模块同名
// 冲突(入口 main、按名查找)。根模块(mod 0)保持原名。'$' 不是 SPL 标识符字符,
// 因此 "$<mod>$<name>" 与任何未改编名都不冲突。
type .{ .ByteBuffer } = @import("../stage2/utils/byte_buffer.spl");
type .{ .append_usize } = @import("../stage2/utils/fmt.spl");
fn needs_mangling(mod: usize): bool {
ret mod != 0;
}
fn mangle(mod: usize, name: []u8, out: *ByteBuffer) {
ByteBuffer.append_byte(out, '$');
append_usize(out, mod, 10, false);
ByteBuffer.append_byte(out, '$');
ByteBuffer.append(out, name);
}
fn main() {}