From 7b978bf1e05727f15fc83ae7d2455c08833cc439 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Wed, 5 Oct 2022 05:34:52 -0700 Subject: stage2: Rename `Value.compare` to `compareAll`, etc. These functions have a very error-prone API. They are essentially `all(cmp(op, ...))` but that's not reflected in the name. This renames these functions to `compareAllAgainstZero...` etc. for clarity and fixes >20 locations where the predicate was incorrect. In the future, the scalar `compare` should probably be split off from the vector comparison. Rank-polymorphic programming is great, but a proper implementation in Zig would decouple comparison and reduction, which then needs a way to fuse ops at comptime. --- src/RangeSet.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/RangeSet.zig') diff --git a/src/RangeSet.zig b/src/RangeSet.zig index 84cae34365..a5007ef7c8 100644 --- a/src/RangeSet.zig +++ b/src/RangeSet.zig @@ -35,8 +35,8 @@ pub fn add( src: SwitchProngSrc, ) !?SwitchProngSrc { for (self.ranges.items) |range| { - if (last.compare(.gte, range.first, ty, self.module) and - first.compare(.lte, range.last, ty, self.module)) + if (last.compareAll(.gte, range.first, ty, self.module) and + first.compareAll(.lte, range.last, ty, self.module)) { return range.src; // They overlap. } @@ -53,7 +53,7 @@ const LessThanContext = struct { ty: Type, module: *Module }; /// Assumes a and b do not overlap fn lessThan(ctx: LessThanContext, a: Range, b: Range) bool { - return a.first.compare(.lt, b.first, ctx.ty, ctx.module); + return a.first.compareAll(.lt, b.first, ctx.ty, ctx.module); } pub fn spans(self: *RangeSet, first: Value, last: Value, ty: Type) !bool { -- cgit v1.2.3