| ... | ... | @@ -797,7 +797,7 @@ const DocData = struct { |
| 797 | 797 | } |
| 798 | 798 | }; |
| 799 | 799 | |
| 800 | | /// An Expr represents the (untyped) result of analizing instructions. |
| 800 | /// An Expr represents the (untyped) result of analyzing instructions. |
| 801 | 801 | /// The data is normalized, which means that an Expr that results in a |
| 802 | 802 | /// type definition will hold an index into `self.types`. |
| 803 | 803 | pub const Expr = union(enum) { |
| ... | ... | @@ -1262,6 +1262,12 @@ fn walkInstruction( |
| 1262 | 1262 | .expr = .{ .int_big = .{ .value = as_string } }, |
| 1263 | 1263 | }; |
| 1264 | 1264 | }, |
| 1265 | .@"unreachable" => { |
| 1266 | return DocData.WalkResult{ |
| 1267 | .typeRef = .{ .type = @intFromEnum(Ref.noreturn_type) }, |
| 1268 | .expr = .{ .@"unreachable" = .{} }, |
| 1269 | }; |
| 1270 | }, |
| 1265 | 1271 | |
| 1266 | 1272 | .slice_start => { |
| 1267 | 1273 | const pl_node = data[inst_index].pl_node; |
| ... | ... | @@ -1580,6 +1586,7 @@ fn walkInstruction( |
| 1580 | 1586 | .frame_size, |
| 1581 | 1587 | .int_from_ptr, |
| 1582 | 1588 | .bit_not, |
| 1589 | .bool_not, |
| 1583 | 1590 | // @check |
| 1584 | 1591 | .clz, |
| 1585 | 1592 | .ctz, |
| ... | ... | @@ -1602,6 +1609,40 @@ fn walkInstruction( |
| 1602 | 1609 | .expr = .{ .builtinIndex = bin_index }, |
| 1603 | 1610 | }; |
| 1604 | 1611 | }, |
| 1612 | .bool_br_and, .bool_br_or => { |
| 1613 | const bool_br = data[inst_index].bool_br; |
| 1614 | |
| 1615 | const bin_index = self.exprs.items.len; |
| 1616 | try self.exprs.append(self.arena, .{ .binOp = .{ .lhs = 0, .rhs = 0 } }); |
| 1617 | |
| 1618 | const lhs = try self.walkRef( |
| 1619 | file, |
| 1620 | parent_scope, |
| 1621 | parent_src, |
| 1622 | bool_br.lhs, |
| 1623 | false, |
| 1624 | ); |
| 1625 | const lhs_index = self.exprs.items.len; |
| 1626 | try self.exprs.append(self.arena, lhs.expr); |
| 1627 | |
| 1628 | const extra = file.zir.extraData(Zir.Inst.Block, bool_br.payload_index); |
| 1629 | const rhs = try self.walkInstruction( |
| 1630 | file, |
| 1631 | parent_scope, |
| 1632 | parent_src, |
| 1633 | file.zir.extra[extra.end..][extra.data.body_len - 1], |
| 1634 | false, |
| 1635 | ); |
| 1636 | const rhs_index = self.exprs.items.len; |
| 1637 | try self.exprs.append(self.arena, rhs.expr); |
| 1638 | |
| 1639 | self.exprs.items[bin_index] = .{ .binOp = .{ .name = @tagName(tags[inst_index]), .lhs = lhs_index, .rhs = rhs_index } }; |
| 1640 | |
| 1641 | return DocData.WalkResult{ |
| 1642 | .typeRef = .{ .type = @intFromEnum(Ref.bool_type) }, |
| 1643 | .expr = .{ .binOpIndex = bin_index }, |
| 1644 | }; |
| 1645 | }, |
| 1605 | 1646 | .truncate => { |
| 1606 | 1647 | // in the ZIR this node is a builtin `bin` but we want send it as a `un` builtin |
| 1607 | 1648 | const pl_node = data[inst_index].pl_node; |
| ... | ... | @@ -2359,6 +2400,16 @@ fn walkInstruction( |
| 2359 | 2400 | need_type, |
| 2360 | 2401 | ); |
| 2361 | 2402 | }, |
| 2403 | .break_inline => { |
| 2404 | const @"break" = data[inst_index].@"break"; |
| 2405 | return try self.walkRef( |
| 2406 | file, |
| 2407 | parent_scope, |
| 2408 | parent_src, |
| 2409 | @"break".operand, |
| 2410 | need_type, |
| 2411 | ); |
| 2412 | }, |
| 2362 | 2413 | .struct_init => { |
| 2363 | 2414 | const pl_node = data[inst_index].pl_node; |
| 2364 | 2415 | const extra = file.zir.extraData(Zir.Inst.StructInit, pl_node.payload_index); |