diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-05-18 21:24:42 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-05-20 02:47:20 -0700 |
| commit | fcd4efd8ecda01fe06735ed8b7e2cd2aa93daa19 (patch) | |
| tree | adc90f10a7a762b65350a1de3fd36bc7e2bb071b /src/TypedValue.zig | |
| parent | cd04b49041200b36c5af23ac3700cbfa82f037ca (diff) | |
| download | zig-fcd4efd8ecda01fe06735ed8b7e2cd2aa93daa19.tar.gz zig-fcd4efd8ecda01fe06735ed8b7e2cd2aa93daa19.zip | |
Sema: introduce laziness to `@sizeOf`
Motivation: the behavior test that is now passing.
The main change in this commit is introducing `Type.abiSizeAdvanced`,
`Value.Tag.lazy_size`, and adjusting `Sema.zirSizeOf` to take advantage
of these.
However, the bulk of lines changed in this commit ended up being moving
logic from value.zig and type.zig into Sema.zig. This logic had no
business being in Type/Value as it was only called from a Sema context,
and we need access to the Sema context for error reporting when a lazy
Value is resolved.
Also worth mentioning is that I bumped up the comptime `@floatToInt`
implementation from using f64 to f128.
Diffstat (limited to 'src/TypedValue.zig')
| -rw-r--r-- | src/TypedValue.zig | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/TypedValue.zig b/src/TypedValue.zig index 43c26b254e..b6aee29a4b 100644 --- a/src/TypedValue.zig +++ b/src/TypedValue.zig @@ -232,6 +232,11 @@ pub fn print( const x = sub_ty.abiAlignment(target); return writer.print("{d}", .{x}); }, + .lazy_size => { + const sub_ty = val.castTag(.lazy_size).?.data; + const x = sub_ty.abiSize(target); + return writer.print("{d}", .{x}); + }, .function => return writer.print("(function '{s}')", .{ mod.declPtr(val.castTag(.function).?.data.owner_decl).name, }), |
