| author | |
| committer | |
| log | 91424823724de866776c8b6a999ea45f1ca9d374 |
| tree | 43c794431c7e5d83dc434117cca5884d8e01c672 |
| parent | 75df7e502c05e7e6a9b00a5a28854ae4a1aa8ea6 |
| signature |
29 files changed, 162 insertions(+), 177 deletions(-)
lib/compiler/aro/aro/Preprocessor.zig+2-2| ... | ... | @@ -2446,7 +2446,7 @@ pub fn expandedSlice(pp: *const Preprocessor, tok: anytype) []const u8 { |
| 2446 | 2446 | |
| 2447 | 2447 | /// Concat two tokens and add the result to pp.generated |
| 2448 | 2448 | fn pasteTokens(pp: *Preprocessor, lhs_toks: *ExpandBuf, rhs_toks: []const TokenWithExpansionLocs) Error!void { |
| 2449 | const lhs = while (lhs_toks.popOrNull()) |lhs| { | |
| 2449 | const lhs = while (lhs_toks.pop()) |lhs| { | |
| 2450 | 2450 | if ((pp.comp.langopts.preserve_comments_in_macros and lhs.id == .comment) or |
| 2451 | 2451 | (lhs.id != .macro_ws and lhs.id != .comment)) |
| 2452 | 2452 | break lhs; |
| ... | ... | @@ -2676,7 +2676,7 @@ fn defineFn(pp: *Preprocessor, tokenizer: *Tokenizer, define_tok: RawToken, macr |
| 2676 | 2676 | tok = tokenizer.nextNoWS(); |
| 2677 | 2677 | if (tok.id == .ellipsis) { |
| 2678 | 2678 | try pp.err(tok, .gnu_va_macro); |
| 2679 | gnu_var_args = params.pop(); | |
| 2679 | gnu_var_args = params.pop().?; | |
| 2680 | 2680 | const r_paren = tokenizer.nextNoWS(); |
| 2681 | 2681 | if (r_paren.id != .r_paren) { |
| 2682 | 2682 | try pp.err(r_paren, .missing_paren_param_list); |
lib/compiler/aro/aro/pragmas/gcc.zig+1-1| ... | ... | @@ -103,7 +103,7 @@ fn diagnosticHandler(self: *GCC, pp: *Preprocessor, start_idx: TokenIndex) Pragm |
| 103 | 103 | try pp.comp.diagnostics.set(str[2..], new_kind); |
| 104 | 104 | }, |
| 105 | 105 | .push => try self.options_stack.append(pp.comp.gpa, pp.comp.diagnostics.options), |
| 106 | .pop => pp.comp.diagnostics.options = self.options_stack.popOrNull() orelse self.original_options, | |
| 106 | .pop => pp.comp.diagnostics.options = self.options_stack.pop() orelse self.original_options, | |
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 |
lib/compiler/aro/aro/pragmas/pack.zig+1-1| ... | ... | @@ -149,7 +149,7 @@ fn pop(pack: *Pack, p: *Parser, maybe_label: ?[]const u8) void { |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | } else { |
| 152 | const prev = pack.stack.popOrNull() orelse { | |
| 152 | const prev = pack.stack.pop() orelse { | |
| 153 | 153 | p.pragma_pack = 2; |
| 154 | 154 | return; |
| 155 | 155 | }; |
lib/compiler/build_runner.zig+1-1| ... | ... | @@ -1190,7 +1190,7 @@ pub fn printErrorMessages( |
| 1190 | 1190 | const ttyconf = options.ttyconf; |
| 1191 | 1191 | try ttyconf.setColor(stderr, .dim); |
| 1192 | 1192 | var indent: usize = 0; |
| 1193 | while (step_stack.popOrNull()) |s| : (indent += 1) { | |
| 1193 | while (step_stack.pop()) |s| : (indent += 1) { | |
| 1194 | 1194 | if (indent > 0) { |
| 1195 | 1195 | try stderr.writer().writeByteNTimes(' ', (indent - 1) * 3); |
| 1196 | 1196 | try printChildNodePrefix(stderr, ttyconf); |
lib/docs/wasm/markdown/Parser.zig+1-1| ... | ... | @@ -816,7 +816,7 @@ fn isThematicBreak(line: []const u8) bool { |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | 818 | fn closeLastBlock(p: *Parser) !void { |
| 819 | const b = p.pending_blocks.pop(); | |
| 819 | const b = p.pending_blocks.pop().?; | |
| 820 | 820 | const node = switch (b.tag) { |
| 821 | 821 | .list => list: { |
| 822 | 822 | assert(b.string_start == p.scratch_string.items.len); |
lib/std/Build/Step/ConfigHeader.zig+1-1| ... | ... | @@ -616,7 +616,7 @@ fn expand_variables_cmake( |
| 616 | 616 | // no open bracket, preserve as a literal |
| 617 | 617 | break :blk; |
| 618 | 618 | } |
| 619 | const open_pos = var_stack.pop(); | |
| 619 | const open_pos = var_stack.pop().?; | |
| 620 | 620 | if (source_offset == open_pos.source) { |
| 621 | 621 | source_offset += open_var.len; |
| 622 | 622 | } |
lib/std/array_list.zig+16-31| ... | ... | @@ -289,10 +289,10 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { |
| 289 | 289 | /// Asserts that the list is not empty. |
| 290 | 290 | /// Asserts that the index is in bounds. |
| 291 | 291 | pub fn swapRemove(self: *Self, i: usize) T { |
| 292 | if (self.items.len - 1 == i) return self.pop(); | |
| 292 | if (self.items.len - 1 == i) return self.pop().?; | |
| 293 | 293 | |
| 294 | 294 | const old_item = self.items[i]; |
| 295 | self.items[i] = self.pop(); | |
| 295 | self.items[i] = self.pop().?; | |
| 296 | 296 | return old_item; |
| 297 | 297 | } |
| 298 | 298 | |
| ... | ... | @@ -555,23 +555,15 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { |
| 555 | 555 | return self.items[prev_len..][0..n]; |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | /// Remove and return the last element from the list. | |
| 559 | /// Invalidates element pointers to the removed element. | |
| 560 | /// Asserts that the list is not empty. | |
| 561 | pub fn pop(self: *Self) T { | |
| 558 | /// Remove and return the last element from the list, or return `null` if list is empty. | |
| 559 | /// Invalidates element pointers to the removed element, if any. | |
| 560 | pub fn pop(self: *Self) ?T { | |
| 561 | if (self.items.len == 0) return null; | |
| 562 | 562 | const val = self.items[self.items.len - 1]; |
| 563 | 563 | self.items.len -= 1; |
| 564 | 564 | return val; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | /// Remove and return the last element from the list, or | |
| 568 | /// return `null` if list is empty. | |
| 569 | /// Invalidates element pointers to the removed element, if any. | |
| 570 | pub fn popOrNull(self: *Self) ?T { | |
| 571 | if (self.items.len == 0) return null; | |
| 572 | return self.pop(); | |
| 573 | } | |
| 574 | ||
| 575 | 567 | /// Returns a slice of all the items plus the extra capacity, whose memory |
| 576 | 568 | /// contents are `undefined`. |
| 577 | 569 | pub fn allocatedSlice(self: Self) Slice { |
| ... | ... | @@ -897,10 +889,10 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ |
| 897 | 889 | /// Asserts that the list is not empty. |
| 898 | 890 | /// Asserts that the index is in bounds. |
| 899 | 891 | pub fn swapRemove(self: *Self, i: usize) T { |
| 900 | if (self.items.len - 1 == i) return self.pop(); | |
| 892 | if (self.items.len - 1 == i) return self.pop().?; | |
| 901 | 893 | |
| 902 | 894 | const old_item = self.items[i]; |
| 903 | self.items[i] = self.pop(); | |
| 895 | self.items[i] = self.pop().?; | |
| 904 | 896 | return old_item; |
| 905 | 897 | } |
| 906 | 898 | |
| ... | ... | @@ -1190,22 +1182,15 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ |
| 1190 | 1182 | } |
| 1191 | 1183 | |
| 1192 | 1184 | /// Remove and return the last element from the list. |
| 1185 | /// If the list is empty, returns `null`. | |
| 1193 | 1186 | /// Invalidates pointers to last element. |
| 1194 | /// Asserts that the list is not empty. | |
| 1195 | pub fn pop(self: *Self) T { | |
| 1187 | pub fn pop(self: *Self) ?T { | |
| 1188 | if (self.items.len == 0) return null; | |
| 1196 | 1189 | const val = self.items[self.items.len - 1]; |
| 1197 | 1190 | self.items.len -= 1; |
| 1198 | 1191 | return val; |
| 1199 | 1192 | } |
| 1200 | 1193 | |
| 1201 | /// Remove and return the last element from the list. | |
| 1202 | /// If the list is empty, returns `null`. | |
| 1203 | /// Invalidates pointers to last element. | |
| 1204 | pub fn popOrNull(self: *Self) ?T { | |
| 1205 | if (self.items.len == 0) return null; | |
| 1206 | return self.pop(); | |
| 1207 | } | |
| 1208 | ||
| 1209 | 1194 | /// Returns a slice of all the items plus the extra capacity, whose memory |
| 1210 | 1195 | /// contents are `undefined`. |
| 1211 | 1196 | pub fn allocatedSlice(self: Self) Slice { |
| ... | ... | @@ -2184,7 +2169,7 @@ test "ArrayList(u0)" { |
| 2184 | 2169 | try testing.expectEqual(count, 3); |
| 2185 | 2170 | } |
| 2186 | 2171 | |
| 2187 | test "ArrayList(?u32).popOrNull()" { | |
| 2172 | test "ArrayList(?u32).pop()" { | |
| 2188 | 2173 | const a = testing.allocator; |
| 2189 | 2174 | |
| 2190 | 2175 | var list = ArrayList(?u32).init(a); |
| ... | ... | @@ -2195,10 +2180,10 @@ test "ArrayList(?u32).popOrNull()" { |
| 2195 | 2180 | try list.append(2); |
| 2196 | 2181 | try testing.expectEqual(list.items.len, 3); |
| 2197 | 2182 | |
| 2198 | try testing.expect(list.popOrNull().? == @as(u32, 2)); | |
| 2199 | try testing.expect(list.popOrNull().? == @as(u32, 1)); | |
| 2200 | try testing.expect(list.popOrNull().? == null); | |
| 2201 | try testing.expect(list.popOrNull() == null); | |
| 2183 | try testing.expect(list.pop().? == @as(u32, 2)); | |
| 2184 | try testing.expect(list.pop().? == @as(u32, 1)); | |
| 2185 | try testing.expect(list.pop().? == null); | |
| 2186 | try testing.expect(list.pop() == null); | |
| 2202 | 2187 | } |
| 2203 | 2188 | |
| 2204 | 2189 | test "ArrayList(u32).getLast()" { |
lib/std/debug/Dwarf/expression.zig+68-68| ... | ... | @@ -527,14 +527,14 @@ pub fn StackMachine(comptime options: Options) type { |
| 527 | 527 | }, |
| 528 | 528 | OP.@"and" => { |
| 529 | 529 | if (self.stack.items.len < 2) return error.InvalidExpression; |
| 530 | const a = try self.stack.pop().asIntegral(); | |
| 530 | const a = try self.stack.pop().?.asIntegral(); | |
| 531 | 531 | self.stack.items[self.stack.items.len - 1] = .{ |
| 532 | 532 | .generic = a & try self.stack.items[self.stack.items.len - 1].asIntegral(), |
| 533 | 533 | }; |
| 534 | 534 | }, |
| 535 | 535 | OP.div => { |
| 536 | 536 | if (self.stack.items.len < 2) return error.InvalidExpression; |
| 537 | const a: isize = @bitCast(try self.stack.pop().asIntegral()); | |
| 537 | const a: isize = @bitCast(try self.stack.pop().?.asIntegral()); | |
| 538 | 538 | const b: isize = @bitCast(try self.stack.items[self.stack.items.len - 1].asIntegral()); |
| 539 | 539 | self.stack.items[self.stack.items.len - 1] = .{ |
| 540 | 540 | .generic = @bitCast(try std.math.divTrunc(isize, b, a)), |
| ... | ... | @@ -542,14 +542,14 @@ pub fn StackMachine(comptime options: Options) type { |
| 542 | 542 | }, |
| 543 | 543 | OP.minus => { |
| 544 | 544 | if (self.stack.items.len < 2) return error.InvalidExpression; |
| 545 | const b = try self.stack.pop().asIntegral(); | |
| 545 | const b = try self.stack.pop().?.asIntegral(); | |
| 546 | 546 | self.stack.items[self.stack.items.len - 1] = .{ |
| 547 | 547 | .generic = try std.math.sub(addr_type, try self.stack.items[self.stack.items.len - 1].asIntegral(), b), |
| 548 | 548 | }; |
| 549 | 549 | }, |
| 550 | 550 | OP.mod => { |
| 551 | 551 | if (self.stack.items.len < 2) return error.InvalidExpression; |
| 552 | const a: isize = @bitCast(try self.stack.pop().asIntegral()); | |
| 552 | const a: isize = @bitCast(try self.stack.pop().?.asIntegral()); | |
| 553 | 553 | const b: isize = @bitCast(try self.stack.items[self.stack.items.len - 1].asIntegral()); |
| 554 | 554 | self.stack.items[self.stack.items.len - 1] = .{ |
| 555 | 555 | .generic = @bitCast(@mod(b, a)), |
| ... | ... | @@ -557,7 +557,7 @@ pub fn StackMachine(comptime options: Options) type { |
| 557 | 557 | }, |
| 558 | 558 | OP.mul => { |
| 559 | 559 | if (self.stack.items.len < 2) return error.InvalidExpression; |
| 560 | const a: isize = @bitCast(try self.stack.pop().asIntegral()); | |
| 560 | const a: isize = @bitCast(try self.stack.pop().?.asIntegral()); | |
| 561 | 561 | const b: isize = @bitCast(try self.stack.items[self.stack.items.len - 1].asIntegral()); |
| 562 | 562 | self.stack.items[self.stack.items.len - 1] = .{ |
| 563 | 563 | .generic = @bitCast(@mulWithOverflow(a, b)[0]), |
| ... | ... | @@ -581,14 +581,14 @@ pub fn StackMachine(comptime options: Options) type { |
| 581 | 581 | }, |
| 582 | 582 | OP.@"or" => { |
| 583 | 583 | if (self.stack.items.len < 2) return error.InvalidExpression; |
| 584 | const a = try self.stack.pop().asIntegral(); | |
| 584 | const a = try self.stack.pop().?.asIntegral(); | |
| 585 | 585 | self.stack.items[self.stack.items.len - 1] = .{ |
| 586 | 586 | .generic = a | try self.stack.items[self.stack.items.len - 1].asIntegral(), |
| 587 | 587 | }; |
| 588 | 588 | }, |
| 589 | 589 | OP.plus => { |
| 590 | 590 | if (self.stack.items.len < 2) return error.InvalidExpression; |
| 591 | const b = try self.stack.pop().asIntegral(); | |
| 591 | const b = try self.stack.pop().?.asIntegral(); | |
| 592 | 592 | self.stack.items[self.stack.items.len - 1] = .{ |
| 593 | 593 | .generic = try std.math.add(addr_type, try self.stack.items[self.stack.items.len - 1].asIntegral(), b), |
| 594 | 594 | }; |
| ... | ... | @@ -602,7 +602,7 @@ pub fn StackMachine(comptime options: Options) type { |
| 602 | 602 | }, |
| 603 | 603 | OP.shl => { |
| 604 | 604 | if (self.stack.items.len < 2) return error.InvalidExpression; |
| 605 | const a = try self.stack.pop().asIntegral(); | |
| 605 | const a = try self.stack.pop().?.asIntegral(); | |
| 606 | 606 | const b = try self.stack.items[self.stack.items.len - 1].asIntegral(); |
| 607 | 607 | self.stack.items[self.stack.items.len - 1] = .{ |
| 608 | 608 | .generic = std.math.shl(usize, b, a), |
| ... | ... | @@ -610,7 +610,7 @@ pub fn StackMachine(comptime options: Options) type { |
| 610 | 610 | }, |
| 611 | 611 | OP.shr => { |
| 612 | 612 | if (self.stack.items.len < 2) return error.InvalidExpression; |
| 613 | const a = try self.stack.pop().asIntegral(); | |
| 613 | const a = try self.stack.pop().?.asIntegral(); | |
| 614 | 614 | const b = try self.stack.items[self.stack.items.len - 1].asIntegral(); |
| 615 | 615 | self.stack.items[self.stack.items.len - 1] = .{ |
| 616 | 616 | .generic = std.math.shr(usize, b, a), |
| ... | ... | @@ -618,7 +618,7 @@ pub fn StackMachine(comptime options: Options) type { |
| 618 | 618 | }, |
| 619 | 619 | OP.shra => { |
| 620 | 620 | if (self.stack.items.len < 2) return error.InvalidExpression; |
| 621 | const a = try self.stack.pop().asIntegral(); | |
| 621 | const a = try self.stack.pop().?.asIntegral(); | |
| 622 | 622 | const b: isize = @bitCast(try self.stack.items[self.stack.items.len - 1].asIntegral()); |
| 623 | 623 | self.stack.items[self.stack.items.len - 1] = .{ |
| 624 | 624 | .generic = @bitCast(std.math.shr(isize, b, a)), |
| ... | ... | @@ -626,7 +626,7 @@ pub fn StackMachine(comptime options: Options) type { |
| 626 | 626 | }, |
| 627 | 627 | OP.xor => { |
| 628 | 628 | if (self.stack.items.len < 2) return error.InvalidExpression; |
| 629 | const a = try self.stack.pop().asIntegral(); | |
| 629 | const a = try self.stack.pop().?.asIntegral(); | |
| 630 | 630 | self.stack.items[self.stack.items.len - 1] = .{ |
| 631 | 631 | .generic = a ^ try self.stack.items[self.stack.items.len - 1].asIntegral(), |
| 632 | 632 | }; |
| ... | ... | @@ -641,7 +641,7 @@ pub fn StackMachine(comptime options: Options) type { |
| 641 | 641 | OP.ne, |
| 642 | 642 | => { |
| 643 | 643 | if (self.stack.items.len < 2) return error.InvalidExpression; |
| 644 | const a = self.stack.pop(); | |
| 644 | const a = self.stack.pop().?; | |
| 645 | 645 | const b = self.stack.items[self.stack.items.len - 1]; |
| 646 | 646 | |
| 647 | 647 | if (a == .generic and b == .generic) { |
| ... | ... | @@ -667,7 +667,7 @@ pub fn StackMachine(comptime options: Options) type { |
| 667 | 667 | const branch_offset = operand.?.branch_offset; |
| 668 | 668 | const condition = if (opcode == OP.bra) blk: { |
| 669 | 669 | if (self.stack.items.len == 0) return error.InvalidExpression; |
| 670 | break :blk try self.stack.pop().asIntegral() != 0; | |
| 670 | break :blk try self.stack.pop().?.asIntegral() != 0; | |
| 671 | 671 | } else true; |
| 672 | 672 | |
| 673 | 673 | if (condition) { |
| ... | ... | @@ -1080,7 +1080,7 @@ test "DWARF expressions" { |
| 1080 | 1080 | |
| 1081 | 1081 | for (0..32) |i| { |
| 1082 | 1082 | const expected = 31 - i; |
| 1083 | try testing.expectEqual(expected, stack_machine.stack.popOrNull().?.generic); | |
| 1083 | try testing.expectEqual(expected, stack_machine.stack.pop().?.generic); | |
| 1084 | 1084 | } |
| 1085 | 1085 | } |
| 1086 | 1086 | |
| ... | ... | @@ -1141,7 +1141,7 @@ test "DWARF expressions" { |
| 1141 | 1141 | |
| 1142 | 1142 | _ = try stack_machine.run(program.items, allocator, context, 0); |
| 1143 | 1143 | |
| 1144 | const const_type = stack_machine.stack.popOrNull().?.const_type; | |
| 1144 | const const_type = stack_machine.stack.pop().?.const_type; | |
| 1145 | 1145 | try testing.expectEqual(die_offset, const_type.type_offset); |
| 1146 | 1146 | try testing.expectEqualSlices(u8, type_bytes, const_type.value_bytes); |
| 1147 | 1147 | |
| ... | ... | @@ -1162,7 +1162,7 @@ test "DWARF expressions" { |
| 1162 | 1162 | }; |
| 1163 | 1163 | |
| 1164 | 1164 | inline for (expected) |e| { |
| 1165 | try testing.expectEqual(@as(e[0], e[1]), @as(e[2], @bitCast(stack_machine.stack.popOrNull().?.generic))); | |
| 1165 | try testing.expectEqual(@as(e[0], e[1]), @as(e[2], @bitCast(stack_machine.stack.pop().?.generic))); | |
| 1166 | 1166 | } |
| 1167 | 1167 | } |
| 1168 | 1168 | |
| ... | ... | @@ -1199,14 +1199,14 @@ test "DWARF expressions" { |
| 1199 | 1199 | |
| 1200 | 1200 | _ = try stack_machine.run(program.items, allocator, context, 0); |
| 1201 | 1201 | |
| 1202 | const regval_type = stack_machine.stack.popOrNull().?.regval_type; | |
| 1202 | const regval_type = stack_machine.stack.pop().?.regval_type; | |
| 1203 | 1203 | try testing.expectEqual(@as(usize, 400), regval_type.type_offset); |
| 1204 | 1204 | try testing.expectEqual(@as(u8, @sizeOf(usize)), regval_type.type_size); |
| 1205 | 1205 | try testing.expectEqual(@as(usize, 0xee), regval_type.value); |
| 1206 | 1206 | |
| 1207 | try testing.expectEqual(@as(usize, 303), stack_machine.stack.popOrNull().?.generic); | |
| 1208 | try testing.expectEqual(@as(usize, 202), stack_machine.stack.popOrNull().?.generic); | |
| 1209 | try testing.expectEqual(@as(usize, 101), stack_machine.stack.popOrNull().?.generic); | |
| 1207 | try testing.expectEqual(@as(usize, 303), stack_machine.stack.pop().?.generic); | |
| 1208 | try testing.expectEqual(@as(usize, 202), stack_machine.stack.pop().?.generic); | |
| 1209 | try testing.expectEqual(@as(usize, 101), stack_machine.stack.pop().?.generic); | |
| 1210 | 1210 | } else |err| { |
| 1211 | 1211 | switch (err) { |
| 1212 | 1212 | error.UnimplementedArch, |
| ... | ... | @@ -1227,15 +1227,15 @@ test "DWARF expressions" { |
| 1227 | 1227 | try b.writeConst(writer, u8, 1); |
| 1228 | 1228 | try b.writeOpcode(writer, OP.dup); |
| 1229 | 1229 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1230 | try testing.expectEqual(@as(usize, 1), stack_machine.stack.popOrNull().?.generic); | |
| 1231 | try testing.expectEqual(@as(usize, 1), stack_machine.stack.popOrNull().?.generic); | |
| 1230 | try testing.expectEqual(@as(usize, 1), stack_machine.stack.pop().?.generic); | |
| 1231 | try testing.expectEqual(@as(usize, 1), stack_machine.stack.pop().?.generic); | |
| 1232 | 1232 | |
| 1233 | 1233 | stack_machine.reset(); |
| 1234 | 1234 | program.clearRetainingCapacity(); |
| 1235 | 1235 | try b.writeConst(writer, u8, 1); |
| 1236 | 1236 | try b.writeOpcode(writer, OP.drop); |
| 1237 | 1237 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1238 | try testing.expect(stack_machine.stack.popOrNull() == null); | |
| 1238 | try testing.expect(stack_machine.stack.pop() == null); | |
| 1239 | 1239 | |
| 1240 | 1240 | stack_machine.reset(); |
| 1241 | 1241 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1244,7 +1244,7 @@ test "DWARF expressions" { |
| 1244 | 1244 | try b.writeConst(writer, u8, 6); |
| 1245 | 1245 | try b.writePick(writer, 2); |
| 1246 | 1246 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1247 | try testing.expectEqual(@as(usize, 4), stack_machine.stack.popOrNull().?.generic); | |
| 1247 | try testing.expectEqual(@as(usize, 4), stack_machine.stack.pop().?.generic); | |
| 1248 | 1248 | |
| 1249 | 1249 | stack_machine.reset(); |
| 1250 | 1250 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1253,7 +1253,7 @@ test "DWARF expressions" { |
| 1253 | 1253 | try b.writeConst(writer, u8, 6); |
| 1254 | 1254 | try b.writeOpcode(writer, OP.over); |
| 1255 | 1255 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1256 | try testing.expectEqual(@as(usize, 5), stack_machine.stack.popOrNull().?.generic); | |
| 1256 | try testing.expectEqual(@as(usize, 5), stack_machine.stack.pop().?.generic); | |
| 1257 | 1257 | |
| 1258 | 1258 | stack_machine.reset(); |
| 1259 | 1259 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1261,8 +1261,8 @@ test "DWARF expressions" { |
| 1261 | 1261 | try b.writeConst(writer, u8, 6); |
| 1262 | 1262 | try b.writeOpcode(writer, OP.swap); |
| 1263 | 1263 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1264 | try testing.expectEqual(@as(usize, 5), stack_machine.stack.popOrNull().?.generic); | |
| 1265 | try testing.expectEqual(@as(usize, 6), stack_machine.stack.popOrNull().?.generic); | |
| 1264 | try testing.expectEqual(@as(usize, 5), stack_machine.stack.pop().?.generic); | |
| 1265 | try testing.expectEqual(@as(usize, 6), stack_machine.stack.pop().?.generic); | |
| 1266 | 1266 | |
| 1267 | 1267 | stack_machine.reset(); |
| 1268 | 1268 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1271,9 +1271,9 @@ test "DWARF expressions" { |
| 1271 | 1271 | try b.writeConst(writer, u8, 6); |
| 1272 | 1272 | try b.writeOpcode(writer, OP.rot); |
| 1273 | 1273 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1274 | try testing.expectEqual(@as(usize, 5), stack_machine.stack.popOrNull().?.generic); | |
| 1275 | try testing.expectEqual(@as(usize, 4), stack_machine.stack.popOrNull().?.generic); | |
| 1276 | try testing.expectEqual(@as(usize, 6), stack_machine.stack.popOrNull().?.generic); | |
| 1274 | try testing.expectEqual(@as(usize, 5), stack_machine.stack.pop().?.generic); | |
| 1275 | try testing.expectEqual(@as(usize, 4), stack_machine.stack.pop().?.generic); | |
| 1276 | try testing.expectEqual(@as(usize, 6), stack_machine.stack.pop().?.generic); | |
| 1277 | 1277 | |
| 1278 | 1278 | const deref_target: usize = @truncate(0xffeeffee_ffeeffee); |
| 1279 | 1279 | |
| ... | ... | @@ -1282,7 +1282,7 @@ test "DWARF expressions" { |
| 1282 | 1282 | try b.writeAddr(writer, @intFromPtr(&deref_target)); |
| 1283 | 1283 | try b.writeOpcode(writer, OP.deref); |
| 1284 | 1284 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1285 | try testing.expectEqual(deref_target, stack_machine.stack.popOrNull().?.generic); | |
| 1285 | try testing.expectEqual(deref_target, stack_machine.stack.pop().?.generic); | |
| 1286 | 1286 | |
| 1287 | 1287 | stack_machine.reset(); |
| 1288 | 1288 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1290,14 +1290,14 @@ test "DWARF expressions" { |
| 1290 | 1290 | try b.writeAddr(writer, @intFromPtr(&deref_target)); |
| 1291 | 1291 | try b.writeOpcode(writer, OP.xderef); |
| 1292 | 1292 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1293 | try testing.expectEqual(deref_target, stack_machine.stack.popOrNull().?.generic); | |
| 1293 | try testing.expectEqual(deref_target, stack_machine.stack.pop().?.generic); | |
| 1294 | 1294 | |
| 1295 | 1295 | stack_machine.reset(); |
| 1296 | 1296 | program.clearRetainingCapacity(); |
| 1297 | 1297 | try b.writeAddr(writer, @intFromPtr(&deref_target)); |
| 1298 | 1298 | try b.writeDerefSize(writer, 1); |
| 1299 | 1299 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1300 | try testing.expectEqual(@as(usize, @as(*const u8, @ptrCast(&deref_target)).*), stack_machine.stack.popOrNull().?.generic); | |
| 1300 | try testing.expectEqual(@as(usize, @as(*const u8, @ptrCast(&deref_target)).*), stack_machine.stack.pop().?.generic); | |
| 1301 | 1301 | |
| 1302 | 1302 | stack_machine.reset(); |
| 1303 | 1303 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1305,7 +1305,7 @@ test "DWARF expressions" { |
| 1305 | 1305 | try b.writeAddr(writer, @intFromPtr(&deref_target)); |
| 1306 | 1306 | try b.writeXDerefSize(writer, 1); |
| 1307 | 1307 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1308 | try testing.expectEqual(@as(usize, @as(*const u8, @ptrCast(&deref_target)).*), stack_machine.stack.popOrNull().?.generic); | |
| 1308 | try testing.expectEqual(@as(usize, @as(*const u8, @ptrCast(&deref_target)).*), stack_machine.stack.pop().?.generic); | |
| 1309 | 1309 | |
| 1310 | 1310 | const type_offset: usize = @truncate(0xaabbaabb_aabbaabb); |
| 1311 | 1311 | |
| ... | ... | @@ -1314,7 +1314,7 @@ test "DWARF expressions" { |
| 1314 | 1314 | try b.writeAddr(writer, @intFromPtr(&deref_target)); |
| 1315 | 1315 | try b.writeDerefType(writer, 1, type_offset); |
| 1316 | 1316 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1317 | const deref_type = stack_machine.stack.popOrNull().?.regval_type; | |
| 1317 | const deref_type = stack_machine.stack.pop().?.regval_type; | |
| 1318 | 1318 | try testing.expectEqual(type_offset, deref_type.type_offset); |
| 1319 | 1319 | try testing.expectEqual(@as(u8, 1), deref_type.type_size); |
| 1320 | 1320 | try testing.expectEqual(@as(usize, @as(*const u8, @ptrCast(&deref_target)).*), deref_type.value); |
| ... | ... | @@ -1325,7 +1325,7 @@ test "DWARF expressions" { |
| 1325 | 1325 | try b.writeAddr(writer, @intFromPtr(&deref_target)); |
| 1326 | 1326 | try b.writeXDerefType(writer, 1, type_offset); |
| 1327 | 1327 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1328 | const xderef_type = stack_machine.stack.popOrNull().?.regval_type; | |
| 1328 | const xderef_type = stack_machine.stack.pop().?.regval_type; | |
| 1329 | 1329 | try testing.expectEqual(type_offset, xderef_type.type_offset); |
| 1330 | 1330 | try testing.expectEqual(@as(u8, 1), xderef_type.type_size); |
| 1331 | 1331 | try testing.expectEqual(@as(usize, @as(*const u8, @ptrCast(&deref_target)).*), xderef_type.value); |
| ... | ... | @@ -1336,7 +1336,7 @@ test "DWARF expressions" { |
| 1336 | 1336 | program.clearRetainingCapacity(); |
| 1337 | 1337 | try b.writeOpcode(writer, OP.push_object_address); |
| 1338 | 1338 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1339 | try testing.expectEqual(@as(usize, @intFromPtr(context.object_address.?)), stack_machine.stack.popOrNull().?.generic); | |
| 1339 | try testing.expectEqual(@as(usize, @intFromPtr(context.object_address.?)), stack_machine.stack.pop().?.generic); | |
| 1340 | 1340 | |
| 1341 | 1341 | // TODO: Test OP.form_tls_address |
| 1342 | 1342 | |
| ... | ... | @@ -1346,7 +1346,7 @@ test "DWARF expressions" { |
| 1346 | 1346 | program.clearRetainingCapacity(); |
| 1347 | 1347 | try b.writeOpcode(writer, OP.call_frame_cfa); |
| 1348 | 1348 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1349 | try testing.expectEqual(context.cfa.?, stack_machine.stack.popOrNull().?.generic); | |
| 1349 | try testing.expectEqual(context.cfa.?, stack_machine.stack.pop().?.generic); | |
| 1350 | 1350 | } |
| 1351 | 1351 | |
| 1352 | 1352 | // Arithmetic and Logical Operations |
| ... | ... | @@ -1358,7 +1358,7 @@ test "DWARF expressions" { |
| 1358 | 1358 | try b.writeConst(writer, i16, -4096); |
| 1359 | 1359 | try b.writeOpcode(writer, OP.abs); |
| 1360 | 1360 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1361 | try testing.expectEqual(@as(usize, 4096), stack_machine.stack.popOrNull().?.generic); | |
| 1361 | try testing.expectEqual(@as(usize, 4096), stack_machine.stack.pop().?.generic); | |
| 1362 | 1362 | |
| 1363 | 1363 | stack_machine.reset(); |
| 1364 | 1364 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1366,7 +1366,7 @@ test "DWARF expressions" { |
| 1366 | 1366 | try b.writeConst(writer, u16, 0xf0ff); |
| 1367 | 1367 | try b.writeOpcode(writer, OP.@"and"); |
| 1368 | 1368 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1369 | try testing.expectEqual(@as(usize, 0xf00f), stack_machine.stack.popOrNull().?.generic); | |
| 1369 | try testing.expectEqual(@as(usize, 0xf00f), stack_machine.stack.pop().?.generic); | |
| 1370 | 1370 | |
| 1371 | 1371 | stack_machine.reset(); |
| 1372 | 1372 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1374,7 +1374,7 @@ test "DWARF expressions" { |
| 1374 | 1374 | try b.writeConst(writer, i16, 100); |
| 1375 | 1375 | try b.writeOpcode(writer, OP.div); |
| 1376 | 1376 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1377 | try testing.expectEqual(@as(isize, -404 / 100), @as(isize, @bitCast(stack_machine.stack.popOrNull().?.generic))); | |
| 1377 | try testing.expectEqual(@as(isize, -404 / 100), @as(isize, @bitCast(stack_machine.stack.pop().?.generic))); | |
| 1378 | 1378 | |
| 1379 | 1379 | stack_machine.reset(); |
| 1380 | 1380 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1382,7 +1382,7 @@ test "DWARF expressions" { |
| 1382 | 1382 | try b.writeConst(writer, u16, 50); |
| 1383 | 1383 | try b.writeOpcode(writer, OP.minus); |
| 1384 | 1384 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1385 | try testing.expectEqual(@as(usize, 150), stack_machine.stack.popOrNull().?.generic); | |
| 1385 | try testing.expectEqual(@as(usize, 150), stack_machine.stack.pop().?.generic); | |
| 1386 | 1386 | |
| 1387 | 1387 | stack_machine.reset(); |
| 1388 | 1388 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1390,7 +1390,7 @@ test "DWARF expressions" { |
| 1390 | 1390 | try b.writeConst(writer, u16, 100); |
| 1391 | 1391 | try b.writeOpcode(writer, OP.mod); |
| 1392 | 1392 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1393 | try testing.expectEqual(@as(usize, 23), stack_machine.stack.popOrNull().?.generic); | |
| 1393 | try testing.expectEqual(@as(usize, 23), stack_machine.stack.pop().?.generic); | |
| 1394 | 1394 | |
| 1395 | 1395 | stack_machine.reset(); |
| 1396 | 1396 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1398,7 +1398,7 @@ test "DWARF expressions" { |
| 1398 | 1398 | try b.writeConst(writer, u16, 0xee); |
| 1399 | 1399 | try b.writeOpcode(writer, OP.mul); |
| 1400 | 1400 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1401 | try testing.expectEqual(@as(usize, 0xed12), stack_machine.stack.popOrNull().?.generic); | |
| 1401 | try testing.expectEqual(@as(usize, 0xed12), stack_machine.stack.pop().?.generic); | |
| 1402 | 1402 | |
| 1403 | 1403 | stack_machine.reset(); |
| 1404 | 1404 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1407,15 +1407,15 @@ test "DWARF expressions" { |
| 1407 | 1407 | try b.writeConst(writer, i16, -6); |
| 1408 | 1408 | try b.writeOpcode(writer, OP.neg); |
| 1409 | 1409 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1410 | try testing.expectEqual(@as(usize, 6), stack_machine.stack.popOrNull().?.generic); | |
| 1411 | try testing.expectEqual(@as(isize, -5), @as(isize, @bitCast(stack_machine.stack.popOrNull().?.generic))); | |
| 1410 | try testing.expectEqual(@as(usize, 6), stack_machine.stack.pop().?.generic); | |
| 1411 | try testing.expectEqual(@as(isize, -5), @as(isize, @bitCast(stack_machine.stack.pop().?.generic))); | |
| 1412 | 1412 | |
| 1413 | 1413 | stack_machine.reset(); |
| 1414 | 1414 | program.clearRetainingCapacity(); |
| 1415 | 1415 | try b.writeConst(writer, u16, 0xff0f); |
| 1416 | 1416 | try b.writeOpcode(writer, OP.not); |
| 1417 | 1417 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1418 | try testing.expectEqual(~@as(usize, 0xff0f), stack_machine.stack.popOrNull().?.generic); | |
| 1418 | try testing.expectEqual(~@as(usize, 0xff0f), stack_machine.stack.pop().?.generic); | |
| 1419 | 1419 | |
| 1420 | 1420 | stack_machine.reset(); |
| 1421 | 1421 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1423,7 +1423,7 @@ test "DWARF expressions" { |
| 1423 | 1423 | try b.writeConst(writer, u16, 0xf0ff); |
| 1424 | 1424 | try b.writeOpcode(writer, OP.@"or"); |
| 1425 | 1425 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1426 | try testing.expectEqual(@as(usize, 0xffff), stack_machine.stack.popOrNull().?.generic); | |
| 1426 | try testing.expectEqual(@as(usize, 0xffff), stack_machine.stack.pop().?.generic); | |
| 1427 | 1427 | |
| 1428 | 1428 | stack_machine.reset(); |
| 1429 | 1429 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1431,14 +1431,14 @@ test "DWARF expressions" { |
| 1431 | 1431 | try b.writeConst(writer, i16, 100); |
| 1432 | 1432 | try b.writeOpcode(writer, OP.plus); |
| 1433 | 1433 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1434 | try testing.expectEqual(@as(usize, 502), stack_machine.stack.popOrNull().?.generic); | |
| 1434 | try testing.expectEqual(@as(usize, 502), stack_machine.stack.pop().?.generic); | |
| 1435 | 1435 | |
| 1436 | 1436 | stack_machine.reset(); |
| 1437 | 1437 | program.clearRetainingCapacity(); |
| 1438 | 1438 | try b.writeConst(writer, u16, 4096); |
| 1439 | 1439 | try b.writePlusUconst(writer, @as(usize, 8192)); |
| 1440 | 1440 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1441 | try testing.expectEqual(@as(usize, 4096 + 8192), stack_machine.stack.popOrNull().?.generic); | |
| 1441 | try testing.expectEqual(@as(usize, 4096 + 8192), stack_machine.stack.pop().?.generic); | |
| 1442 | 1442 | |
| 1443 | 1443 | stack_machine.reset(); |
| 1444 | 1444 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1446,7 +1446,7 @@ test "DWARF expressions" { |
| 1446 | 1446 | try b.writeConst(writer, u16, 1); |
| 1447 | 1447 | try b.writeOpcode(writer, OP.shl); |
| 1448 | 1448 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1449 | try testing.expectEqual(@as(usize, 0xfff << 1), stack_machine.stack.popOrNull().?.generic); | |
| 1449 | try testing.expectEqual(@as(usize, 0xfff << 1), stack_machine.stack.pop().?.generic); | |
| 1450 | 1450 | |
| 1451 | 1451 | stack_machine.reset(); |
| 1452 | 1452 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1454,7 +1454,7 @@ test "DWARF expressions" { |
| 1454 | 1454 | try b.writeConst(writer, u16, 1); |
| 1455 | 1455 | try b.writeOpcode(writer, OP.shr); |
| 1456 | 1456 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1457 | try testing.expectEqual(@as(usize, 0xfff >> 1), stack_machine.stack.popOrNull().?.generic); | |
| 1457 | try testing.expectEqual(@as(usize, 0xfff >> 1), stack_machine.stack.pop().?.generic); | |
| 1458 | 1458 | |
| 1459 | 1459 | stack_machine.reset(); |
| 1460 | 1460 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1462,7 +1462,7 @@ test "DWARF expressions" { |
| 1462 | 1462 | try b.writeConst(writer, u16, 1); |
| 1463 | 1463 | try b.writeOpcode(writer, OP.shr); |
| 1464 | 1464 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1465 | try testing.expectEqual(@as(usize, @bitCast(@as(isize, 0xfff) >> 1)), stack_machine.stack.popOrNull().?.generic); | |
| 1465 | try testing.expectEqual(@as(usize, @bitCast(@as(isize, 0xfff) >> 1)), stack_machine.stack.pop().?.generic); | |
| 1466 | 1466 | |
| 1467 | 1467 | stack_machine.reset(); |
| 1468 | 1468 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1470,7 +1470,7 @@ test "DWARF expressions" { |
| 1470 | 1470 | try b.writeConst(writer, u16, 0xff0f); |
| 1471 | 1471 | try b.writeOpcode(writer, OP.xor); |
| 1472 | 1472 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1473 | try testing.expectEqual(@as(usize, 0x0ff0), stack_machine.stack.popOrNull().?.generic); | |
| 1473 | try testing.expectEqual(@as(usize, 0x0ff0), stack_machine.stack.pop().?.generic); | |
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | 1476 | // Control Flow Operations |
| ... | ... | @@ -1499,9 +1499,9 @@ test "DWARF expressions" { |
| 1499 | 1499 | try b.writeConst(writer, u16, 0); |
| 1500 | 1500 | try b.writeOpcode(writer, e[0]); |
| 1501 | 1501 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1502 | try testing.expectEqual(@as(usize, e[3]), stack_machine.stack.popOrNull().?.generic); | |
| 1503 | try testing.expectEqual(@as(usize, e[2]), stack_machine.stack.popOrNull().?.generic); | |
| 1504 | try testing.expectEqual(@as(usize, e[1]), stack_machine.stack.popOrNull().?.generic); | |
| 1502 | try testing.expectEqual(@as(usize, e[3]), stack_machine.stack.pop().?.generic); | |
| 1503 | try testing.expectEqual(@as(usize, e[2]), stack_machine.stack.pop().?.generic); | |
| 1504 | try testing.expectEqual(@as(usize, e[1]), stack_machine.stack.pop().?.generic); | |
| 1505 | 1505 | } |
| 1506 | 1506 | |
| 1507 | 1507 | stack_machine.reset(); |
| ... | ... | @@ -1510,7 +1510,7 @@ test "DWARF expressions" { |
| 1510 | 1510 | try b.writeSkip(writer, 1); |
| 1511 | 1511 | try b.writeLiteral(writer, 3); |
| 1512 | 1512 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1513 | try testing.expectEqual(@as(usize, 2), stack_machine.stack.popOrNull().?.generic); | |
| 1513 | try testing.expectEqual(@as(usize, 2), stack_machine.stack.pop().?.generic); | |
| 1514 | 1514 | |
| 1515 | 1515 | stack_machine.reset(); |
| 1516 | 1516 | program.clearRetainingCapacity(); |
| ... | ... | @@ -1522,9 +1522,9 @@ test "DWARF expressions" { |
| 1522 | 1522 | try b.writeLiteral(writer, 4); |
| 1523 | 1523 | try b.writeLiteral(writer, 5); |
| 1524 | 1524 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1525 | try testing.expectEqual(@as(usize, 5), stack_machine.stack.popOrNull().?.generic); | |
| 1526 | try testing.expectEqual(@as(usize, 4), stack_machine.stack.popOrNull().?.generic); | |
| 1527 | try testing.expect(stack_machine.stack.popOrNull() == null); | |
| 1525 | try testing.expectEqual(@as(usize, 5), stack_machine.stack.pop().?.generic); | |
| 1526 | try testing.expectEqual(@as(usize, 4), stack_machine.stack.pop().?.generic); | |
| 1527 | try testing.expect(stack_machine.stack.pop() == null); | |
| 1528 | 1528 | |
| 1529 | 1529 | // TODO: Test call2, call4, call_ref once implemented |
| 1530 | 1530 | |
| ... | ... | @@ -1548,7 +1548,7 @@ test "DWARF expressions" { |
| 1548 | 1548 | try b.writeConstType(writer, @as(usize, 0), &value_bytes); |
| 1549 | 1549 | try b.writeConvert(writer, @as(usize, 0)); |
| 1550 | 1550 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1551 | try testing.expectEqual(value, stack_machine.stack.popOrNull().?.generic); | |
| 1551 | try testing.expectEqual(value, stack_machine.stack.pop().?.generic); | |
| 1552 | 1552 | |
| 1553 | 1553 | // Reinterpret to generic type |
| 1554 | 1554 | stack_machine.reset(); |
| ... | ... | @@ -1556,7 +1556,7 @@ test "DWARF expressions" { |
| 1556 | 1556 | try b.writeConstType(writer, @as(usize, 0), &value_bytes); |
| 1557 | 1557 | try b.writeReinterpret(writer, @as(usize, 0)); |
| 1558 | 1558 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1559 | try testing.expectEqual(value, stack_machine.stack.popOrNull().?.generic); | |
| 1559 | try testing.expectEqual(value, stack_machine.stack.pop().?.generic); | |
| 1560 | 1560 | |
| 1561 | 1561 | // Reinterpret to new type |
| 1562 | 1562 | const die_offset: usize = 0xffee; |
| ... | ... | @@ -1566,7 +1566,7 @@ test "DWARF expressions" { |
| 1566 | 1566 | try b.writeConstType(writer, @as(usize, 0), &value_bytes); |
| 1567 | 1567 | try b.writeReinterpret(writer, die_offset); |
| 1568 | 1568 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1569 | const const_type = stack_machine.stack.popOrNull().?.const_type; | |
| 1569 | const const_type = stack_machine.stack.pop().?.const_type; | |
| 1570 | 1570 | try testing.expectEqual(die_offset, const_type.type_offset); |
| 1571 | 1571 | |
| 1572 | 1572 | stack_machine.reset(); |
| ... | ... | @@ -1574,7 +1574,7 @@ test "DWARF expressions" { |
| 1574 | 1574 | try b.writeLiteral(writer, 0); |
| 1575 | 1575 | try b.writeReinterpret(writer, die_offset); |
| 1576 | 1576 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1577 | const regval_type = stack_machine.stack.popOrNull().?.regval_type; | |
| 1577 | const regval_type = stack_machine.stack.pop().?.regval_type; | |
| 1578 | 1578 | try testing.expectEqual(die_offset, regval_type.type_offset); |
| 1579 | 1579 | } |
| 1580 | 1580 | |
| ... | ... | @@ -1586,7 +1586,7 @@ test "DWARF expressions" { |
| 1586 | 1586 | program.clearRetainingCapacity(); |
| 1587 | 1587 | try b.writeOpcode(writer, OP.nop); |
| 1588 | 1588 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1589 | try testing.expect(stack_machine.stack.popOrNull() == null); | |
| 1589 | try testing.expect(stack_machine.stack.pop() == null); | |
| 1590 | 1590 | |
| 1591 | 1591 | // Sub-expression |
| 1592 | 1592 | { |
| ... | ... | @@ -1599,7 +1599,7 @@ test "DWARF expressions" { |
| 1599 | 1599 | program.clearRetainingCapacity(); |
| 1600 | 1600 | try b.writeEntryValue(writer, sub_program.items); |
| 1601 | 1601 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1602 | try testing.expectEqual(@as(usize, 3), stack_machine.stack.popOrNull().?.generic); | |
| 1602 | try testing.expectEqual(@as(usize, 3), stack_machine.stack.pop().?.generic); | |
| 1603 | 1603 | } |
| 1604 | 1604 | |
| 1605 | 1605 | // Register location description |
| ... | ... | @@ -1626,7 +1626,7 @@ test "DWARF expressions" { |
| 1626 | 1626 | program.clearRetainingCapacity(); |
| 1627 | 1627 | try b.writeEntryValue(writer, sub_program.items); |
| 1628 | 1628 | _ = try stack_machine.run(program.items, allocator, context, null); |
| 1629 | try testing.expectEqual(@as(usize, 0xee), stack_machine.stack.popOrNull().?.generic); | |
| 1629 | try testing.expectEqual(@as(usize, 0xee), stack_machine.stack.pop().?.generic); | |
| 1630 | 1630 | } else |err| { |
| 1631 | 1631 | switch (err) { |
| 1632 | 1632 | error.UnimplementedArch, |
lib/std/debug/SelfInfo.zig+1-1| ... | ... | @@ -2138,7 +2138,7 @@ pub const VirtualMachine = struct { |
| 2138 | 2138 | self.current_row.copy_on_write = true; |
| 2139 | 2139 | }, |
| 2140 | 2140 | .restore_state => { |
| 2141 | const restored_columns = self.stack.popOrNull() orelse return error.InvalidOperation; | |
| 2141 | const restored_columns = self.stack.pop() orelse return error.InvalidOperation; | |
| 2142 | 2142 | self.columns.shrinkRetainingCapacity(self.columns.items.len - self.current_row.columns.len); |
| 2143 | 2143 | try self.columns.ensureUnusedCapacity(allocator, restored_columns.len); |
| 2144 | 2144 |
lib/std/fs/Dir.zig+2-2| ... | ... | @@ -682,7 +682,7 @@ pub const Walker = struct { |
| 682 | 682 | // walking if they want, which means that we need to pop the directory |
| 683 | 683 | // that errored from the stack. Otherwise, all future `next` calls would |
| 684 | 684 | // likely just fail with the same error. |
| 685 | var item = self.stack.pop(); | |
| 685 | var item = self.stack.pop().?; | |
| 686 | 686 | if (self.stack.items.len != 0) { |
| 687 | 687 | item.iter.dir.close(); |
| 688 | 688 | } |
| ... | ... | @@ -718,7 +718,7 @@ pub const Walker = struct { |
| 718 | 718 | .kind = base.kind, |
| 719 | 719 | }; |
| 720 | 720 | } else { |
| 721 | var item = self.stack.pop(); | |
| 721 | var item = self.stack.pop().?; | |
| 722 | 722 | if (self.stack.items.len != 0) { |
| 723 | 723 | item.iter.dir.close(); |
| 724 | 724 | } |
lib/std/heap.zig+1-1| ... | ... | @@ -681,7 +681,7 @@ pub fn testAllocatorAlignedShrink(base_allocator: mem.Allocator) !void { |
| 681 | 681 | try stuff_to_free.append(slice); |
| 682 | 682 | slice = try allocator.alignedAlloc(u8, 16, alloc_size); |
| 683 | 683 | } |
| 684 | while (stuff_to_free.popOrNull()) |item| { | |
| 684 | while (stuff_to_free.pop()) |item| { | |
| 685 | 685 | allocator.free(item); |
| 686 | 686 | } |
| 687 | 687 | slice[0] = 0x12; |
lib/std/heap/debug_allocator.zig+3-3| ... | ... | @@ -1070,7 +1070,7 @@ test "small allocations - free in reverse order" { |
| 1070 | 1070 | try list.append(ptr); |
| 1071 | 1071 | } |
| 1072 | 1072 | |
| 1073 | while (list.popOrNull()) |ptr| { | |
| 1073 | while (list.pop()) |ptr| { | |
| 1074 | 1074 | allocator.destroy(ptr); |
| 1075 | 1075 | } |
| 1076 | 1076 | } |
| ... | ... | @@ -1227,7 +1227,7 @@ test "shrink large object to large object with larger alignment" { |
| 1227 | 1227 | try stuff_to_free.append(slice); |
| 1228 | 1228 | slice = try allocator.alignedAlloc(u8, 16, alloc_size); |
| 1229 | 1229 | } |
| 1230 | while (stuff_to_free.popOrNull()) |item| { | |
| 1230 | while (stuff_to_free.pop()) |item| { | |
| 1231 | 1231 | allocator.free(item); |
| 1232 | 1232 | } |
| 1233 | 1233 | slice[0] = 0x12; |
| ... | ... | @@ -1299,7 +1299,7 @@ test "realloc large object to larger alignment" { |
| 1299 | 1299 | try stuff_to_free.append(slice); |
| 1300 | 1300 | slice = try allocator.alignedAlloc(u8, 16, default_page_size * 2 + 50); |
| 1301 | 1301 | } |
| 1302 | while (stuff_to_free.popOrNull()) |item| { | |
| 1302 | while (stuff_to_free.pop()) |item| { | |
| 1303 | 1303 | allocator.free(item); |
| 1304 | 1304 | } |
| 1305 | 1305 | slice[0] = 0x12; |
lib/std/json/dynamic.zig+2-2| ... | ... | @@ -124,7 +124,7 @@ pub const Value = union(enum) { |
| 124 | 124 | .array_begin => { |
| 125 | 125 | try stack.append(Value{ .array = Array.init(allocator) }); |
| 126 | 126 | }, |
| 127 | .array_end => return try handleCompleteValue(&stack, allocator, source, stack.pop(), options) orelse continue, | |
| 127 | .array_end => return try handleCompleteValue(&stack, allocator, source, stack.pop().?, options) orelse continue, | |
| 128 | 128 | |
| 129 | 129 | else => unreachable, |
| 130 | 130 | } |
| ... | ... | @@ -171,7 +171,7 @@ fn handleCompleteValue(stack: *Array, allocator: Allocator, source: anytype, val |
| 171 | 171 | switch (try source.nextAllocMax(allocator, .alloc_always, options.max_value_len.?)) { |
| 172 | 172 | .object_end => { |
| 173 | 173 | // This object is complete. |
| 174 | value = stack.pop(); | |
| 174 | value = stack.pop().?; | |
| 175 | 175 | // Effectively recurse now that we have a complete value. |
| 176 | 176 | if (stack.items.len == 0) return value; |
| 177 | 177 | continue; |
src/Compilation.zig+2-2| ... | ... | @@ -657,7 +657,7 @@ pub const CObject = struct { |
| 657 | 657 | .end_block => |block| switch (@as(BlockId, @enumFromInt(block.id))) { |
| 658 | 658 | .Meta => {}, |
| 659 | 659 | .Diag => { |
| 660 | var wip_diag = stack.pop(); | |
| 660 | var wip_diag = stack.pop().?; | |
| 661 | 661 | errdefer wip_diag.deinit(gpa); |
| 662 | 662 | |
| 663 | 663 | const src_ranges = try wip_diag.src_ranges.toOwnedSlice(gpa); |
| ... | ... | @@ -5915,7 +5915,7 @@ pub fn addCCArgs( |
| 5915 | 5915 | try san_arg.appendSlice(arena, "fuzzer-no-link,"); |
| 5916 | 5916 | } |
| 5917 | 5917 | // Chop off the trailing comma and append to argv. |
| 5918 | if (san_arg.popOrNull()) |_| { | |
| 5918 | if (san_arg.pop()) |_| { | |
| 5919 | 5919 | try argv.append(san_arg.items); |
| 5920 | 5920 | |
| 5921 | 5921 | // These args have to be added after the `-fsanitize` arg or |
src/InternPool.zig+2-2| ... | ... | @@ -929,7 +929,7 @@ pub fn addDependency(ip: *InternPool, gpa: Allocator, depender: AnalUnit, depend |
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | // Prepend a new dependency. |
| 932 | const new_index: DepEntry.Index, const ptr = if (ip.free_dep_entries.popOrNull()) |new_index| new: { | |
| 932 | const new_index: DepEntry.Index, const ptr = if (ip.free_dep_entries.pop()) |new_index| new: { | |
| 933 | 933 | break :new .{ new_index, &ip.dep_entries.items[@intFromEnum(new_index)] }; |
| 934 | 934 | } else .{ @enumFromInt(ip.dep_entries.items.len), ip.dep_entries.addOneAssumeCapacity() }; |
| 935 | 935 | if (deps.unwrap()) |old_first| { |
| ... | ... | @@ -960,7 +960,7 @@ pub fn addDependency(ip: *InternPool, gpa: Allocator, depender: AnalUnit, depend |
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | // Prepend a new dependency. |
| 963 | const new_index: DepEntry.Index, const ptr = if (ip.free_dep_entries.popOrNull()) |new_index| new: { | |
| 963 | const new_index: DepEntry.Index, const ptr = if (ip.free_dep_entries.pop()) |new_index| new: { | |
| 964 | 964 | break :new .{ new_index, &ip.dep_entries.items[@intFromEnum(new_index)] }; |
| 965 | 965 | } else .{ @enumFromInt(ip.dep_entries.items.len), ip.dep_entries.addOneAssumeCapacity() }; |
| 966 | 966 | if (gop.found_existing) { |
src/Package/Fetch.zig+1-1| ... | ... | @@ -127,7 +127,7 @@ pub const JobQueue = struct { |
| 127 | 127 | // `Fetch` instances are allocated in prior ones' arenas. |
| 128 | 128 | // Sorry, I know it's a bit weird, but it slightly simplifies the |
| 129 | 129 | // critical section. |
| 130 | while (jq.all_fetches.popOrNull()) |f| f.deinit(); | |
| 130 | while (jq.all_fetches.pop()) |f| f.deinit(); | |
| 131 | 131 | jq.all_fetches.deinit(gpa); |
| 132 | 132 | jq.* = undefined; |
| 133 | 133 | } |
src/Sema.zig+2-2| ... | ... | @@ -3912,7 +3912,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref, |
| 3912 | 3912 | |
| 3913 | 3913 | const tmp_air = sema.getTmpAir(); |
| 3914 | 3914 | |
| 3915 | while (to_map.popOrNull()) |air_ptr| { | |
| 3915 | while (to_map.pop()) |air_ptr| { | |
| 3916 | 3916 | if (ptr_mapping.contains(air_ptr)) continue; |
| 3917 | 3917 | const PointerMethod = union(enum) { |
| 3918 | 3918 | same_addr, |
| ... | ... | @@ -38422,7 +38422,7 @@ pub fn flushExports(sema: *Sema) !void { |
| 38422 | 38422 | // `sema.exports` is completed; store the data into the `Zcu`. |
| 38423 | 38423 | if (sema.exports.items.len == 1) { |
| 38424 | 38424 | try zcu.single_exports.ensureUnusedCapacity(gpa, 1); |
| 38425 | const export_idx: Zcu.Export.Index = zcu.free_exports.popOrNull() orelse idx: { | |
| 38425 | const export_idx: Zcu.Export.Index = zcu.free_exports.pop() orelse idx: { | |
| 38426 | 38426 | _ = try zcu.all_exports.addOne(gpa); |
| 38427 | 38427 | break :idx @enumFromInt(zcu.all_exports.items.len - 1); |
| 38428 | 38428 | }; |
src/Zcu.zig+3-3| ... | ... | @@ -3130,7 +3130,7 @@ pub fn mapOldZirToNew( |
| 3130 | 3130 | } |
| 3131 | 3131 | } |
| 3132 | 3132 | |
| 3133 | while (match_stack.popOrNull()) |match_item| { | |
| 3133 | while (match_stack.pop()) |match_item| { | |
| 3134 | 3134 | // First, a check: if the number of captures of this type has changed, we can't map it, because |
| 3135 | 3135 | // we wouldn't know how to correlate type information with the last update. |
| 3136 | 3136 | // Synchronizes with logic in `Zcu.PerThread.recreateStructType` etc. |
| ... | ... | @@ -3412,7 +3412,7 @@ pub fn addUnitReference(zcu: *Zcu, src_unit: AnalUnit, referenced_unit: AnalUnit |
| 3412 | 3412 | |
| 3413 | 3413 | try zcu.reference_table.ensureUnusedCapacity(gpa, 1); |
| 3414 | 3414 | |
| 3415 | const ref_idx = zcu.free_references.popOrNull() orelse idx: { | |
| 3415 | const ref_idx = zcu.free_references.pop() orelse idx: { | |
| 3416 | 3416 | _ = try zcu.all_references.addOne(gpa); |
| 3417 | 3417 | break :idx zcu.all_references.items.len - 1; |
| 3418 | 3418 | }; |
| ... | ... | @@ -3437,7 +3437,7 @@ pub fn addTypeReference(zcu: *Zcu, src_unit: AnalUnit, referenced_type: InternPo |
| 3437 | 3437 | |
| 3438 | 3438 | try zcu.type_reference_table.ensureUnusedCapacity(gpa, 1); |
| 3439 | 3439 | |
| 3440 | const ref_idx = zcu.free_type_references.popOrNull() orelse idx: { | |
| 3440 | const ref_idx = zcu.free_type_references.pop() orelse idx: { | |
| 3441 | 3441 | _ = try zcu.all_type_references.addOne(gpa); |
| 3442 | 3442 | break :idx zcu.all_type_references.items.len - 1; |
| 3443 | 3443 | }; |
src/arch/aarch64/CodeGen.zig+9-9| ... | ... | @@ -572,7 +572,7 @@ fn gen(self: *Self) !void { |
| 572 | 572 | // dbg_epilogue_begin) is the last exitlude jump |
| 573 | 573 | // relocation (which would just jump one instruction |
| 574 | 574 | // further), it can be safely removed |
| 575 | self.mir_instructions.orderedRemove(self.exitlude_jump_relocs.pop()); | |
| 575 | self.mir_instructions.orderedRemove(self.exitlude_jump_relocs.pop().?); | |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | for (self.exitlude_jump_relocs.items) |jmp_reloc| { |
| ... | ... | @@ -4694,7 +4694,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 4694 | 4694 | |
| 4695 | 4695 | try self.branch_stack.append(.{}); |
| 4696 | 4696 | errdefer { |
| 4697 | _ = self.branch_stack.pop(); | |
| 4697 | _ = self.branch_stack.pop().?; | |
| 4698 | 4698 | } |
| 4699 | 4699 | |
| 4700 | 4700 | try self.ensureProcessDeathCapacity(liveness_condbr.then_deaths.len); |
| ... | ... | @@ -4705,7 +4705,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 4705 | 4705 | |
| 4706 | 4706 | // Revert to the previous register and stack allocation state. |
| 4707 | 4707 | |
| 4708 | var saved_then_branch = self.branch_stack.pop(); | |
| 4708 | var saved_then_branch = self.branch_stack.pop().?; | |
| 4709 | 4709 | defer saved_then_branch.deinit(self.gpa); |
| 4710 | 4710 | |
| 4711 | 4711 | self.register_manager.registers = parent_registers; |
| ... | ... | @@ -4800,7 +4800,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 4800 | 4800 | } |
| 4801 | 4801 | |
| 4802 | 4802 | { |
| 4803 | var item = self.branch_stack.pop(); | |
| 4803 | var item = self.branch_stack.pop().?; | |
| 4804 | 4804 | item.deinit(self.gpa); |
| 4805 | 4805 | } |
| 4806 | 4806 | |
| ... | ... | @@ -5059,7 +5059,7 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) ! |
| 5059 | 5059 | // If the last Mir instruction is the last relocation (which |
| 5060 | 5060 | // would just jump one instruction further), it can be safely |
| 5061 | 5061 | // removed |
| 5062 | self.mir_instructions.orderedRemove(relocs.pop()); | |
| 5062 | self.mir_instructions.orderedRemove(relocs.pop().?); | |
| 5063 | 5063 | } |
| 5064 | 5064 | for (relocs.items) |reloc| { |
| 5065 | 5065 | try self.performReloc(reloc); |
| ... | ... | @@ -5125,7 +5125,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 5125 | 5125 | |
| 5126 | 5126 | try self.branch_stack.append(.{}); |
| 5127 | 5127 | errdefer { |
| 5128 | _ = self.branch_stack.pop(); | |
| 5128 | _ = self.branch_stack.pop().?; | |
| 5129 | 5129 | } |
| 5130 | 5130 | |
| 5131 | 5131 | try self.ensureProcessDeathCapacity(liveness.deaths[case.idx].len); |
| ... | ... | @@ -5135,7 +5135,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 5135 | 5135 | try self.genBody(case.body); |
| 5136 | 5136 | |
| 5137 | 5137 | // Revert to the previous register and stack allocation state. |
| 5138 | var saved_case_branch = self.branch_stack.pop(); | |
| 5138 | var saved_case_branch = self.branch_stack.pop().?; | |
| 5139 | 5139 | defer saved_case_branch.deinit(self.gpa); |
| 5140 | 5140 | |
| 5141 | 5141 | self.register_manager.registers = parent_registers; |
| ... | ... | @@ -5163,7 +5163,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 5163 | 5163 | |
| 5164 | 5164 | try self.branch_stack.append(.{}); |
| 5165 | 5165 | errdefer { |
| 5166 | _ = self.branch_stack.pop(); | |
| 5166 | _ = self.branch_stack.pop().?; | |
| 5167 | 5167 | } |
| 5168 | 5168 | |
| 5169 | 5169 | const else_deaths = liveness.deaths.len - 1; |
| ... | ... | @@ -5174,7 +5174,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 5174 | 5174 | try self.genBody(else_body); |
| 5175 | 5175 | |
| 5176 | 5176 | // Revert to the previous register and stack allocation state. |
| 5177 | var saved_case_branch = self.branch_stack.pop(); | |
| 5177 | var saved_case_branch = self.branch_stack.pop().?; | |
| 5178 | 5178 | defer saved_case_branch.deinit(self.gpa); |
| 5179 | 5179 | |
| 5180 | 5180 | self.register_manager.registers = parent_registers; |
src/arch/arm/CodeGen.zig+9-9| ... | ... | @@ -568,7 +568,7 @@ fn gen(self: *Self) !void { |
| 568 | 568 | // dbg_epilogue_begin) is the last exitlude jump |
| 569 | 569 | // relocation (which would just jump one instruction |
| 570 | 570 | // further), it can be safely removed |
| 571 | self.mir_instructions.orderedRemove(self.exitlude_jump_relocs.pop()); | |
| 571 | self.mir_instructions.orderedRemove(self.exitlude_jump_relocs.pop().?); | |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | for (self.exitlude_jump_relocs.items) |jmp_reloc| { |
| ... | ... | @@ -4669,7 +4669,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { |
| 4669 | 4669 | |
| 4670 | 4670 | try self.branch_stack.append(.{}); |
| 4671 | 4671 | errdefer { |
| 4672 | _ = self.branch_stack.pop(); | |
| 4672 | _ = self.branch_stack.pop().?; | |
| 4673 | 4673 | } |
| 4674 | 4674 | |
| 4675 | 4675 | try self.ensureProcessDeathCapacity(liveness_condbr.then_deaths.len); |
| ... | ... | @@ -4680,7 +4680,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { |
| 4680 | 4680 | |
| 4681 | 4681 | // Revert to the previous register and stack allocation state. |
| 4682 | 4682 | |
| 4683 | var saved_then_branch = self.branch_stack.pop(); | |
| 4683 | var saved_then_branch = self.branch_stack.pop().?; | |
| 4684 | 4684 | defer saved_then_branch.deinit(self.gpa); |
| 4685 | 4685 | |
| 4686 | 4686 | self.register_manager.registers = parent_registers; |
| ... | ... | @@ -4775,7 +4775,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { |
| 4775 | 4775 | } |
| 4776 | 4776 | |
| 4777 | 4777 | { |
| 4778 | var item = self.branch_stack.pop(); | |
| 4778 | var item = self.branch_stack.pop().?; | |
| 4779 | 4779 | item.deinit(self.gpa); |
| 4780 | 4780 | } |
| 4781 | 4781 | |
| ... | ... | @@ -5009,7 +5009,7 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) ! |
| 5009 | 5009 | // If the last Mir instruction is the last relocation (which |
| 5010 | 5010 | // would just jump one instruction further), it can be safely |
| 5011 | 5011 | // removed |
| 5012 | self.mir_instructions.orderedRemove(relocs.pop()); | |
| 5012 | self.mir_instructions.orderedRemove(relocs.pop().?); | |
| 5013 | 5013 | } |
| 5014 | 5014 | for (relocs.items) |reloc| { |
| 5015 | 5015 | try self.performReloc(reloc); |
| ... | ... | @@ -5074,7 +5074,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void { |
| 5074 | 5074 | |
| 5075 | 5075 | try self.branch_stack.append(.{}); |
| 5076 | 5076 | errdefer { |
| 5077 | _ = self.branch_stack.pop(); | |
| 5077 | _ = self.branch_stack.pop().?; | |
| 5078 | 5078 | } |
| 5079 | 5079 | |
| 5080 | 5080 | try self.ensureProcessDeathCapacity(liveness.deaths[case.idx].len); |
| ... | ... | @@ -5084,7 +5084,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void { |
| 5084 | 5084 | try self.genBody(case.body); |
| 5085 | 5085 | |
| 5086 | 5086 | // Revert to the previous register and stack allocation state. |
| 5087 | var saved_case_branch = self.branch_stack.pop(); | |
| 5087 | var saved_case_branch = self.branch_stack.pop().?; | |
| 5088 | 5088 | defer saved_case_branch.deinit(self.gpa); |
| 5089 | 5089 | |
| 5090 | 5090 | self.register_manager.registers = parent_registers; |
| ... | ... | @@ -5112,7 +5112,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void { |
| 5112 | 5112 | |
| 5113 | 5113 | try self.branch_stack.append(.{}); |
| 5114 | 5114 | errdefer { |
| 5115 | _ = self.branch_stack.pop(); | |
| 5115 | _ = self.branch_stack.pop().?; | |
| 5116 | 5116 | } |
| 5117 | 5117 | |
| 5118 | 5118 | const else_deaths = liveness.deaths.len - 1; |
| ... | ... | @@ -5123,7 +5123,7 @@ fn airSwitch(self: *Self, inst: Air.Inst.Index) !void { |
| 5123 | 5123 | try self.genBody(else_body); |
| 5124 | 5124 | |
| 5125 | 5125 | // Revert to the previous register and stack allocation state. |
| 5126 | var saved_case_branch = self.branch_stack.pop(); | |
| 5126 | var saved_case_branch = self.branch_stack.pop().?; | |
| 5127 | 5127 | defer saved_case_branch.deinit(self.gpa); |
| 5128 | 5128 | |
| 5129 | 5129 | self.register_manager.registers = parent_registers; |
src/arch/sparc64/CodeGen.zig+5-5| ... | ... | @@ -392,7 +392,7 @@ fn gen(self: *Self) !void { |
| 392 | 392 | // dbg_epilogue_begin) is the last exitlude jump |
| 393 | 393 | // relocation (which would just jump two instructions |
| 394 | 394 | // further), it can be safely removed |
| 395 | const index = self.exitlude_jump_relocs.pop(); | |
| 395 | const index = self.exitlude_jump_relocs.pop().?; | |
| 396 | 396 | |
| 397 | 397 | // First, remove the delay slot, then remove |
| 398 | 398 | // the branch instruction itself. |
| ... | ... | @@ -1147,7 +1147,7 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) ! |
| 1147 | 1147 | // If the last Mir instruction is the last relocation (which |
| 1148 | 1148 | // would just jump two instruction further), it can be safely |
| 1149 | 1149 | // removed |
| 1150 | const index = relocs.pop(); | |
| 1150 | const index = relocs.pop().?; | |
| 1151 | 1151 | |
| 1152 | 1152 | // First, remove the delay slot, then remove |
| 1153 | 1153 | // the branch instruction itself. |
| ... | ... | @@ -1501,7 +1501,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { |
| 1501 | 1501 | |
| 1502 | 1502 | try self.branch_stack.append(.{}); |
| 1503 | 1503 | errdefer { |
| 1504 | _ = self.branch_stack.pop(); | |
| 1504 | _ = self.branch_stack.pop().?; | |
| 1505 | 1505 | } |
| 1506 | 1506 | |
| 1507 | 1507 | try self.ensureProcessDeathCapacity(liveness_condbr.then_deaths.len); |
| ... | ... | @@ -1512,7 +1512,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { |
| 1512 | 1512 | |
| 1513 | 1513 | // Revert to the previous register and stack allocation state. |
| 1514 | 1514 | |
| 1515 | var saved_then_branch = self.branch_stack.pop(); | |
| 1515 | var saved_then_branch = self.branch_stack.pop().?; | |
| 1516 | 1516 | defer saved_then_branch.deinit(self.gpa); |
| 1517 | 1517 | |
| 1518 | 1518 | self.register_manager.registers = parent_registers; |
| ... | ... | @@ -1608,7 +1608,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { |
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | 1610 | { |
| 1611 | var item = self.branch_stack.pop(); | |
| 1611 | var item = self.branch_stack.pop().?; | |
| 1612 | 1612 | item.deinit(self.gpa); |
| 1613 | 1613 | } |
| 1614 | 1614 |
src/arch/wasm/CodeGen.zig+11-11| ... | ... | @@ -1121,11 +1121,11 @@ fn allocLocal(cg: *CodeGen, ty: Type) InnerError!WValue { |
| 1121 | 1121 | const zcu = cg.pt.zcu; |
| 1122 | 1122 | const valtype = typeToValtype(ty, zcu, cg.target); |
| 1123 | 1123 | const index_or_null = switch (valtype) { |
| 1124 | .i32 => cg.free_locals_i32.popOrNull(), | |
| 1125 | .i64 => cg.free_locals_i64.popOrNull(), | |
| 1126 | .f32 => cg.free_locals_f32.popOrNull(), | |
| 1127 | .f64 => cg.free_locals_f64.popOrNull(), | |
| 1128 | .v128 => cg.free_locals_v128.popOrNull(), | |
| 1124 | .i32 => cg.free_locals_i32.pop(), | |
| 1125 | .i64 => cg.free_locals_i64.pop(), | |
| 1126 | .f32 => cg.free_locals_f32.pop(), | |
| 1127 | .f64 => cg.free_locals_f64.pop(), | |
| 1128 | .v128 => cg.free_locals_v128.pop(), | |
| 1129 | 1129 | }; |
| 1130 | 1130 | if (index_or_null) |index| { |
| 1131 | 1131 | log.debug("reusing local ({d}) of type {}", .{ index, valtype }); |
| ... | ... | @@ -1309,7 +1309,7 @@ fn functionInner(cg: *CodeGen, any_returns: bool) InnerError!Function { |
| 1309 | 1309 | try cg.branches.append(cg.gpa, .{}); |
| 1310 | 1310 | // clean up outer branch |
| 1311 | 1311 | defer { |
| 1312 | var outer_branch = cg.branches.pop(); | |
| 1312 | var outer_branch = cg.branches.pop().?; | |
| 1313 | 1313 | outer_branch.deinit(cg.gpa); |
| 1314 | 1314 | assert(cg.branches.items.len == 0); // missing branch merge |
| 1315 | 1315 | } |
| ... | ... | @@ -3482,7 +3482,7 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 3482 | 3482 | cg.branches.appendAssumeCapacity(.{}); |
| 3483 | 3483 | try cg.currentBranch().values.ensureUnusedCapacity(cg.gpa, @as(u32, @intCast(liveness_condbr.else_deaths.len))); |
| 3484 | 3484 | defer { |
| 3485 | var else_stack = cg.branches.pop(); | |
| 3485 | var else_stack = cg.branches.pop().?; | |
| 3486 | 3486 | else_stack.deinit(cg.gpa); |
| 3487 | 3487 | } |
| 3488 | 3488 | try cg.genBody(else_body); |
| ... | ... | @@ -3494,7 +3494,7 @@ fn airCondBr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 3494 | 3494 | cg.branches.appendAssumeCapacity(.{}); |
| 3495 | 3495 | try cg.currentBranch().values.ensureUnusedCapacity(cg.gpa, @as(u32, @intCast(liveness_condbr.then_deaths.len))); |
| 3496 | 3496 | defer { |
| 3497 | var then_stack = cg.branches.pop(); | |
| 3497 | var then_stack = cg.branches.pop().?; | |
| 3498 | 3498 | then_stack.deinit(cg.gpa); |
| 3499 | 3499 | } |
| 3500 | 3500 | try cg.genBody(then_body); |
| ... | ... | @@ -4132,7 +4132,7 @@ fn airSwitchBr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4132 | 4132 | cg.branches.appendAssumeCapacity(.{}); |
| 4133 | 4133 | try cg.currentBranch().values.ensureUnusedCapacity(cg.gpa, liveness.deaths[index].len); |
| 4134 | 4134 | defer { |
| 4135 | var case_branch = cg.branches.pop(); | |
| 4135 | var case_branch = cg.branches.pop().?; | |
| 4136 | 4136 | case_branch.deinit(cg.gpa); |
| 4137 | 4137 | } |
| 4138 | 4138 | try cg.genBody(case.body); |
| ... | ... | @@ -4144,7 +4144,7 @@ fn airSwitchBr(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4144 | 4144 | const else_deaths = liveness.deaths.len - 1; |
| 4145 | 4145 | try cg.currentBranch().values.ensureUnusedCapacity(cg.gpa, liveness.deaths[else_deaths].len); |
| 4146 | 4146 | defer { |
| 4147 | var else_branch = cg.branches.pop(); | |
| 4147 | var else_branch = cg.branches.pop().?; | |
| 4148 | 4148 | else_branch.deinit(cg.gpa); |
| 4149 | 4149 | } |
| 4150 | 4150 | try cg.genBody(else_body); |
| ... | ... | @@ -6459,7 +6459,7 @@ fn lowerTry( |
| 6459 | 6459 | try cg.branches.append(cg.gpa, .{}); |
| 6460 | 6460 | try cg.currentBranch().values.ensureUnusedCapacity(cg.gpa, liveness.else_deaths.len + liveness.then_deaths.len); |
| 6461 | 6461 | defer { |
| 6462 | var branch = cg.branches.pop(); | |
| 6462 | var branch = cg.branches.pop().?; | |
| 6463 | 6463 | branch.deinit(cg.gpa); |
| 6464 | 6464 | } |
| 6465 | 6465 | try cg.genBody(body); |
src/link.zig+1-1| ... | ... | @@ -1888,7 +1888,7 @@ pub fn resolveInputs( |
| 1888 | 1888 | // that this library search logic can be applied to them. |
| 1889 | 1889 | mem.reverse(UnresolvedInput, unresolved_inputs.items); |
| 1890 | 1890 | |
| 1891 | syslib: while (unresolved_inputs.popOrNull()) |unresolved_input| { | |
| 1891 | syslib: while (unresolved_inputs.pop()) |unresolved_input| { | |
| 1892 | 1892 | const name_query: UnresolvedInput.NameQuery = switch (unresolved_input) { |
| 1893 | 1893 | .name_query => |nq| nq, |
| 1894 | 1894 | .ambiguous_name => |an| an: { |
src/link/Coff.zig+4-4| ... | ... | @@ -707,7 +707,7 @@ pub fn allocateSymbol(coff: *Coff) !u32 { |
| 707 | 707 | try coff.locals.ensureUnusedCapacity(gpa, 1); |
| 708 | 708 | |
| 709 | 709 | const index = blk: { |
| 710 | if (coff.locals_free_list.popOrNull()) |index| { | |
| 710 | if (coff.locals_free_list.pop()) |index| { | |
| 711 | 711 | log.debug(" (reusing symbol index {d})", .{index}); |
| 712 | 712 | break :blk index; |
| 713 | 713 | } else { |
| ... | ... | @@ -735,7 +735,7 @@ fn allocateGlobal(coff: *Coff) !u32 { |
| 735 | 735 | try coff.globals.ensureUnusedCapacity(gpa, 1); |
| 736 | 736 | |
| 737 | 737 | const index = blk: { |
| 738 | if (coff.globals_free_list.popOrNull()) |index| { | |
| 738 | if (coff.globals_free_list.pop()) |index| { | |
| 739 | 739 | log.debug(" (reusing global index {d})", .{index}); |
| 740 | 740 | break :blk index; |
| 741 | 741 | } else { |
| ... | ... | @@ -861,7 +861,7 @@ fn writeAtom(coff: *Coff, atom_index: Atom.Index, code: []u8) !void { |
| 861 | 861 | try coff.pwriteAll(code, file_offset); |
| 862 | 862 | |
| 863 | 863 | // Now we can mark the relocs as resolved. |
| 864 | while (relocs.popOrNull()) |reloc| { | |
| 864 | while (relocs.pop()) |reloc| { | |
| 865 | 865 | reloc.dirty = false; |
| 866 | 866 | } |
| 867 | 867 | } |
| ... | ... | @@ -3670,7 +3670,7 @@ const ImportTable = struct { |
| 3670 | 3670 | fn addImport(itab: *ImportTable, allocator: Allocator, target: SymbolWithLoc) !ImportIndex { |
| 3671 | 3671 | try itab.entries.ensureUnusedCapacity(allocator, 1); |
| 3672 | 3672 | const index: u32 = blk: { |
| 3673 | if (itab.free_list.popOrNull()) |index| { | |
| 3673 | if (itab.free_list.pop()) |index| { | |
| 3674 | 3674 | log.debug(" (reusing import entry index {d})", .{index}); |
| 3675 | 3675 | break :blk index; |
| 3676 | 3676 | } else { |
src/link/Dwarf.zig+4-4| ... | ... | @@ -363,7 +363,7 @@ pub const Section = struct { |
| 363 | 363 | fn popUnit(sec: *Section, gpa: std.mem.Allocator) void { |
| 364 | 364 | const unit_index: Unit.Index = @enumFromInt(sec.units.items.len - 1); |
| 365 | 365 | sec.unlinkUnit(unit_index); |
| 366 | var unit = sec.units.pop(); | |
| 366 | var unit = sec.units.pop().?; | |
| 367 | 367 | unit.deinit(gpa); |
| 368 | 368 | } |
| 369 | 369 | |
| ... | ... | @@ -1559,7 +1559,7 @@ pub const WipNav = struct { |
| 1559 | 1559 | |
| 1560 | 1560 | pub fn leaveBlock(wip_nav: *WipNav, code_off: u64) UpdateError!void { |
| 1561 | 1561 | const block_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.block)); |
| 1562 | const block = wip_nav.blocks.pop(); | |
| 1562 | const block = wip_nav.blocks.pop().?; | |
| 1563 | 1563 | if (wip_nav.any_children) |
| 1564 | 1564 | try uleb128(wip_nav.debug_info.writer(wip_nav.dwarf.gpa), @intFromEnum(AbbrevCode.null)) |
| 1565 | 1565 | else |
| ... | ... | @@ -1599,7 +1599,7 @@ pub const WipNav = struct { |
| 1599 | 1599 | |
| 1600 | 1600 | pub fn leaveInlineFunc(wip_nav: *WipNav, func: InternPool.Index, code_off: u64) UpdateError!void { |
| 1601 | 1601 | const inlined_func_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.inlined_func)); |
| 1602 | const block = wip_nav.blocks.pop(); | |
| 1602 | const block = wip_nav.blocks.pop().?; | |
| 1603 | 1603 | if (wip_nav.any_children) |
| 1604 | 1604 | try uleb128(wip_nav.debug_info.writer(wip_nav.dwarf.gpa), @intFromEnum(AbbrevCode.null)) |
| 1605 | 1605 | else |
| ... | ... | @@ -2054,7 +2054,7 @@ pub const WipNav = struct { |
| 2054 | 2054 | |
| 2055 | 2055 | fn updateLazy(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc) UpdateError!void { |
| 2056 | 2056 | const ip = &wip_nav.pt.zcu.intern_pool; |
| 2057 | while (wip_nav.pending_lazy.popOrNull()) |val| switch (ip.typeOf(val)) { | |
| 2057 | while (wip_nav.pending_lazy.pop()) |val| switch (ip.typeOf(val)) { | |
| 2058 | 2058 | .type_type => try wip_nav.dwarf.updateLazyType(wip_nav.pt, src_loc, val, &wip_nav.pending_lazy), |
| 2059 | 2059 | else => try wip_nav.dwarf.updateLazyValue(wip_nav.pt, src_loc, val, &wip_nav.pending_lazy), |
| 2060 | 2060 | }; |
src/link/Plan9.zig+2-2| ... | ... | @@ -515,7 +515,7 @@ fn updateFinish(self: *Plan9, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index |
| 515 | 515 | |
| 516 | 516 | fn allocateSymbolIndex(self: *Plan9) !usize { |
| 517 | 517 | const gpa = self.base.comp.gpa; |
| 518 | if (self.syms_index_free_list.popOrNull()) |i| { | |
| 518 | if (self.syms_index_free_list.pop()) |i| { | |
| 519 | 519 | return i; |
| 520 | 520 | } else { |
| 521 | 521 | _ = try self.syms.addOne(gpa); |
| ... | ... | @@ -524,7 +524,7 @@ fn allocateSymbolIndex(self: *Plan9) !usize { |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | fn allocateGotIndex(self: *Plan9) usize { |
| 527 | if (self.got_index_free_list.popOrNull()) |i| { | |
| 527 | if (self.got_index_free_list.pop()) |i| { | |
| 528 | 528 | return i; |
| 529 | 529 | } else { |
| 530 | 530 | self.got_len += 1; |
src/link/table_section.zig+1-1| ... | ... | @@ -13,7 +13,7 @@ pub fn TableSection(comptime Entry: type) type { |
| 13 | 13 | pub fn allocateEntry(self: *Self, allocator: Allocator, entry: Entry) Allocator.Error!Index { |
| 14 | 14 | try self.entries.ensureUnusedCapacity(allocator, 1); |
| 15 | 15 | const index = blk: { |
| 16 | if (self.free_list.popOrNull()) |index| { | |
| 16 | if (self.free_list.pop()) |index| { | |
| 17 | 17 | log.debug(" (reusing entry index {d})", .{index}); |
| 18 | 18 | break :blk index; |
| 19 | 19 | } else { |
tools/process_headers.zig+3-3| ... | ... | @@ -192,7 +192,7 @@ pub fn main() !void { |
| 192 | 192 | var dir_stack = std.ArrayList([]const u8).init(allocator); |
| 193 | 193 | try dir_stack.append(target_include_dir); |
| 194 | 194 | |
| 195 | while (dir_stack.popOrNull()) |full_dir_name| { | |
| 195 | while (dir_stack.pop()) |full_dir_name| { | |
| 196 | 196 | var dir = std.fs.cwd().openDir(full_dir_name, .{ .iterate = true }) catch |err| switch (err) { |
| 197 | 197 | error.FileNotFound => continue :search, |
| 198 | 198 | error.AccessDenied => continue :search, |
| ... | ... | @@ -273,14 +273,14 @@ pub fn main() !void { |
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | std.mem.sort(*Contents, contents_list.items, {}, Contents.hitCountLessThan); |
| 276 | const best_contents = contents_list.popOrNull().?; | |
| 276 | const best_contents = contents_list.pop().?; | |
| 277 | 277 | if (best_contents.hit_count > 1) { |
| 278 | 278 | // worth it to make it generic |
| 279 | 279 | const full_path = try std.fs.path.join(allocator, &[_][]const u8{ out_dir, generic_name, path_kv.key_ptr.* }); |
| 280 | 280 | try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?); |
| 281 | 281 | try std.fs.cwd().writeFile(.{ .sub_path = full_path, .data = best_contents.bytes }); |
| 282 | 282 | best_contents.is_generic = true; |
| 283 | while (contents_list.popOrNull()) |contender| { | |
| 283 | while (contents_list.pop()) |contender| { | |
| 284 | 284 | if (contender.hit_count > 1) { |
| 285 | 285 | const this_missed_bytes = contender.hit_count * contender.bytes.len; |
| 286 | 286 | missed_opportunity_bytes += this_missed_bytes; |
tools/update-linux-headers.zig+3-3| ... | ... | @@ -189,7 +189,7 @@ pub fn main() !void { |
| 189 | 189 | var dir_stack = std.ArrayList([]const u8).init(arena); |
| 190 | 190 | try dir_stack.append(target_include_dir); |
| 191 | 191 | |
| 192 | while (dir_stack.popOrNull()) |full_dir_name| { | |
| 192 | while (dir_stack.pop()) |full_dir_name| { | |
| 193 | 193 | var dir = std.fs.cwd().openDir(full_dir_name, .{ .iterate = true }) catch |err| switch (err) { |
| 194 | 194 | error.FileNotFound => continue :search, |
| 195 | 195 | error.AccessDenied => continue :search, |
| ... | ... | @@ -270,14 +270,14 @@ pub fn main() !void { |
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | std.mem.sort(*Contents, contents_list.items, {}, Contents.hitCountLessThan); |
| 273 | const best_contents = contents_list.popOrNull().?; | |
| 273 | const best_contents = contents_list.pop().?; | |
| 274 | 274 | if (best_contents.hit_count > 1) { |
| 275 | 275 | // worth it to make it generic |
| 276 | 276 | const full_path = try std.fs.path.join(arena, &[_][]const u8{ out_dir, generic_name, path_kv.key_ptr.* }); |
| 277 | 277 | try std.fs.cwd().makePath(std.fs.path.dirname(full_path).?); |
| 278 | 278 | try std.fs.cwd().writeFile(.{ .sub_path = full_path, .data = best_contents.bytes }); |
| 279 | 279 | best_contents.is_generic = true; |
| 280 | while (contents_list.popOrNull()) |contender| { | |
| 280 | while (contents_list.pop()) |contender| { | |
| 281 | 281 | if (contender.hit_count > 1) { |
| 282 | 282 | const this_missed_bytes = contender.hit_count * contender.bytes.len; |
| 283 | 283 | missed_opportunity_bytes += this_missed_bytes; |