aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/type.zig b/src/type.zig
index e1a407011b..a43c80cb2e 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -252,6 +252,14 @@ pub const Type = extern union {
};
}
+ /// If it is a function pointer, returns the function type. Otherwise returns null.
+ pub fn castPtrToFn(ty: Type) ?Type {
+ if (ty.zigTypeTag() != .Pointer) return null;
+ const elem_ty = ty.childType();
+ if (elem_ty.zigTypeTag() != .Fn) return null;
+ return elem_ty;
+ }
+
pub fn ptrIsMutable(ty: Type) bool {
return switch (ty.tag()) {
.single_const_pointer_to_comptime_int,