aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/type.zig b/src/type.zig
index 59f0668770..bdddaab070 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -4643,13 +4643,27 @@ pub const Type = extern union {
}
/// Asserts the type is a function.
- pub fn fnCallingConventionAllowsZigTypes(self: Type) bool {
- return switch (self.fnCallingConvention()) {
+ pub fn fnCallingConventionAllowsZigTypes(cc: std.builtin.CallingConvention) bool {
+ return switch (cc) {
.Unspecified, .Async, .Inline, .PtxKernel => true,
else => false,
};
}
+ pub fn isValidParamType(self: Type) bool {
+ return switch (self.zigTypeTagOrPoison() catch return true) {
+ .Undefined, .Null, .Opaque, .NoReturn => false,
+ else => true,
+ };
+ }
+
+ pub fn isValidReturnType(self: Type) bool {
+ return switch (self.zigTypeTagOrPoison() catch return true) {
+ .Undefined, .Null, .Opaque => false,
+ else => true,
+ };
+ }
+
/// Asserts the type is a function.
pub fn fnIsVarArgs(self: Type) bool {
return switch (self.tag()) {
@@ -5650,6 +5664,10 @@ pub const Type = extern union {
const union_obj = ty.cast(Payload.Union).?.data;
return union_obj.srcLoc(mod);
},
+ .@"opaque" => {
+ const opaque_obj = ty.cast(Payload.Opaque).?.data;
+ return opaque_obj.srcLoc(mod);
+ },
.atomic_order,
.atomic_rmw_op,
.calling_convention,