diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2024-03-26 04:19:50 +0000 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2024-03-26 13:48:07 +0000 |
| commit | 0d8c7ae0078e970af39a3be760f25c51829b44f9 (patch) | |
| tree | 1d83b176db748416d4c0c9621c2c1141401dfd5c /src/Module.zig | |
| parent | 920f2c7794ba9b3eb3f3b78c60a0caf544f68927 (diff) | |
| download | zig-0d8c7ae0078e970af39a3be760f25c51829b44f9.tar.gz zig-0d8c7ae0078e970af39a3be760f25c51829b44f9.zip | |
Zcu.Decl: replace `typedValue` with `valueOrFail`
Now that the legacy `Value` representation is eliminated, we can begin
to phase out the redundant `TypedValue` type.
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/Module.zig b/src/Module.zig index 419205c30f..6f65cf8d2e 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -480,17 +480,11 @@ pub const Decl = struct { return decl.val.typeOf(zcu); } - pub fn typedValue(decl: Decl, zcu: *const Zcu) error{AnalysisFail}!TypedValue { + /// Small wrapper for Sema to use over direct access to the `val` field. + /// If the value is not populated, instead returns `error.AnalysisFail`. + pub fn valueOrFail(decl: Decl) error{AnalysisFail}!Value { if (!decl.has_tv) return error.AnalysisFail; - return .{ - .ty = decl.typeOf(zcu), - .val = decl.val, - }; - } - - pub fn isFunction(decl: Decl, zcu: *const Zcu) !bool { - const tv = try decl.typedValue(zcu); - return tv.ty.zigTypeTag(zcu) == .Fn; + return decl.val; } /// If the Decl owns its value and it is a struct, return it, |
