Commit a7bd1a631b
Changed files (2)
src
arch
wasm
src/arch/wasm/CodeGen.zig
@@ -1022,7 +1022,7 @@ fn emitWValue(cg: *CodeGen, value: WValue) InnerError!void {
const comp = wasm.base.comp;
const zcu = comp.zcu.?;
const ip = &zcu.intern_pool;
- if (ip.getNav(nav_ref.nav_index).isExternOrFn(ip)) {
+ if (ip.getNav(nav_ref.nav_index).isFn(ip)) {
assert(nav_ref.offset == 0);
const gop = try wasm.zcu_indirect_function_set.getOrPut(comp.gpa, nav_ref.nav_index);
if (!gop.found_existing) gop.value_ptr.* = {};
src/InternPool.zig
@@ -616,6 +616,20 @@ pub const Nav = struct {
};
}
+ pub fn isFn(nav: Nav, ip: *const InternPool) bool {
+ return switch (nav.status) {
+ .unresolved => unreachable,
+ .type_resolved => |r| {
+ const tag = ip.zigTypeTagOrPoison(r.type) catch unreachable;
+ return tag == .@"fn";
+ },
+ .fully_resolved => |r| {
+ const tag = ip.zigTypeTagOrPoison(ip.typeOf(r.val)) catch unreachable;
+ return tag == .@"fn";
+ },
+ };
+ }
+
/// If this returns `true`, then a pointer to this `Nav` might actually be encoded as a pointer
/// to some other `Nav` due to an extern definition or extern alias (see #21027).
/// This query is valid on `Nav`s for whom only the type is resolved.