Zir: refactor declaration instruction representation
The new representation is often more compact. It is also more straightforward to understand: for instance, `extern` is represented on the `declaration` instruction itself rather than using a special instruction. The same applies to `var`, making both of these far more compact. This commit also separates the type and value bodies of a `declaration` instruction. This is a prerequisite for #131. In general, `declaration` now directly encodes details of the syntax form used, and the embedded ZIR bodies are for actual expressions. The only exception to this is functions, where ZIR is effectively designed as if we had #1717. `extern fn` declarations are modeled as `extern const` with a function type, and normal `fn` definitions are modeled as `const` with a `func{,_fancy,_inferred}` instruction. This may change in the future, but improving on this was out of scope for this commit.
This commit is contained in:
@@ -853,7 +853,7 @@ fn genNavRef(
|
||||
|
||||
const nav_index, const is_extern, const lib_name, const is_threadlocal = switch (ip.indexToKey(zcu.navValue(ref_nav_index).toIntern())) {
|
||||
.func => |func| .{ func.owner_nav, false, .none, false },
|
||||
.variable => |variable| .{ variable.owner_nav, false, variable.lib_name, variable.is_threadlocal },
|
||||
.variable => |variable| .{ variable.owner_nav, false, .none, variable.is_threadlocal },
|
||||
.@"extern" => |@"extern"| .{ @"extern".owner_nav, true, @"extern".lib_name, @"extern".is_threadlocal },
|
||||
else => .{ ref_nav_index, false, .none, false },
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user