╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ RangeSet.zig ─────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
57 !set.list.items(.last)[set.list.len - 1].eql(last, ty, zcu)) 58 { 59 return false; 60 } 61 62 const limbs = try allocator.alloc( 63 math.big.Limb, 64 math.big.int.calcTwosCompLimbCount(ty.intInfo(zcu).bits), 65 ); 66 defer allocator.free(limbs); 67 var counter: math.big.int.Mutable = .init(limbs, 0); 68 69 var space: InternPool.Key.Int.Storage.BigIntSpace = undefined; 70 71 // look for gaps 72 for ( 73 set.list.items(.first)[1..], 74 set.list.items(.last)[0 .. set.list.len - 1], 75 ) |cur_first, prev_last| { 76 // prev_last + 1 == cur_first 77 counter.copy(prev_last.toBigInt(&space, zcu)); 78 counter.addScalar(counter.toConst(), 1); 79 80 const cur_start_int = cur_first.toBigInt(&space, zcu); 81 if (!cur_start_int.eql(counter.toConst())) { 82 return false; 83 } 84 } 85 86 return true; 87 } 88 89 const SearchCtx = struct { 90 val: Value, 91 zcu: *const Zcu, 92 }; 93 fn compare(ctx: SearchCtx, other: Value) math.Order { 94 return ctx.val.order(other, ctx.zcu); 95 } 96 97 const SortCtx = struct { 98 ty: Type, 99 zcu: *Zcu, 100 }; 101 fn lessThan(ctx: SortCtx, a: Value, b: Value) bool { 102 return a.compareScalar(.lt, b, ctx.ty, ctx.zcu); 103 } 104 105 const std = @import("std"); 106 const math = std.math; 107 const assert = std.debug.assert; 108 const Allocator = std.mem.Allocator; 109 110 const InternPool = @import("InternPool.zig"); 111 const Type = @import("Type.zig"); 112 const Value = @import("Value.zig"); 113 const Zcu = @import("Zcu.zig"); 114 const LazySrcLoc = Zcu.LazySrcLoc; 115