aboutsummaryrefslogtreecommitdiff
path: root/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast')
-rw-r--r--src/ast/base.zig5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ast/base.zig b/src/ast/base.zig
index 9e42818de..904ad97bd 100644
--- a/src/ast/base.zig
+++ b/src/ast/base.zig
@@ -33,6 +33,9 @@ pub const Ref = packed struct {
.inner_index = std.math.maxInt(Ref.Int),
.source_index = std.math.maxInt(Ref.Int),
};
+ pub fn toInt(int: anytype) Int {
+ return std.math.cast(Ref.Int, int) catch 0;
+ }
pub fn isNull(self: *const Ref) bool {
return self.source_index == std.math.maxInt(Ref.Int) and self.inner_index == std.math.maxInt(Ref.Int);
}
@@ -41,7 +44,7 @@ pub const Ref = packed struct {
return self.source_index == std.math.maxInt(Ref.Int);
}
- pub fn isSourceIndexNull(int: Ref.Int) bool {
+ pub fn isSourceIndexNull(int: anytype) bool {
return int == std.math.maxInt(Ref.Int);
}