| ... | ... | @@ -575,7 +575,7 @@ const DocData = struct { |
| 575 | 575 | call: usize, // index in `calls` |
| 576 | 576 | enumLiteral: []const u8, // direct value |
| 577 | 577 | typeOf: usize, // index in `exprs` |
| 578 | | typeOf_peer: []Expr, |
| 578 | typeOf_peer: []usize, |
| 579 | 579 | as: As, |
| 580 | 580 | sizeOf: usize, // index in `exprs` |
| 581 | 581 | compileError: []const u8, |
| ... | ... | @@ -642,14 +642,6 @@ const DocData = struct { |
| 642 | 642 | options, |
| 643 | 643 | w, |
| 644 | 644 | ), |
| 645 | | .typeOf_peer => |v| { |
| 646 | | try w.print("{{ \"typeOf_peer\": [", .{}); |
| 647 | | for (v) |c, i| { |
| 648 | | const comma = if (i == v.len - 1) "]}" else ",\n"; |
| 649 | | try c.jsonStringify(options, w); |
| 650 | | try w.print("{s}", .{comma}); |
| 651 | | } |
| 652 | | }, |
| 653 | 645 | .refPath => |v| { |
| 654 | 646 | try w.print("{{ \"refPath\": [", .{}); |
| 655 | 647 | for (v) |c, i| { |
| ... | ... | @@ -658,6 +650,11 @@ const DocData = struct { |
| 658 | 650 | try w.print("{s}", .{comma}); |
| 659 | 651 | } |
| 660 | 652 | }, |
| 653 | .typeOf_peer => |v| try std.json.stringify( |
| 654 | struct { typeOf_peer: []usize }{ .typeOf_peer = v }, |
| 655 | options, |
| 656 | w, |
| 657 | ), |
| 661 | 658 | .array => |v| try std.json.stringify( |
| 662 | 659 | struct { @"array": []usize }{ .@"array" = v }, |
| 663 | 660 | options, |
| ... | ... | @@ -1538,12 +1535,6 @@ fn walkInstruction( |
| 1538 | 1535 | const extra = file.zir.extraData(Zir.Inst.Param, pl_tok.payload_index); |
| 1539 | 1536 | const name = file.zir.nullTerminatedString(extra.data.name); |
| 1540 | 1537 | |
| 1541 | | std.debug.print("param\n", .{}); |
| 1542 | | std.debug.print("pl_tok = {any}\n", .{pl_tok}); |
| 1543 | | std.debug.print("extra = {any}\n", .{extra}); |
| 1544 | | std.debug.print("name = {any}\n", .{name}); |
| 1545 | | std.debug.print("param\n", .{}); |
| 1546 | | |
| 1547 | 1538 | const cte_slot_index = self.comptime_exprs.items.len; |
| 1548 | 1539 | try self.comptime_exprs.append(self.arena, .{ |
| 1549 | 1540 | .code = name, |
| ... | ... | @@ -1616,17 +1607,38 @@ fn walkInstruction( |
| 1616 | 1607 | // Zir says it's a NodeMultiOp but in this case it's TypeOfPeer |
| 1617 | 1608 | const extra = file.zir.extraData(Zir.Inst.TypeOfPeer, extended.operand); |
| 1618 | 1609 | const args = file.zir.refSlice(extra.end, extended.small); |
| 1619 | | const operand_index = self.exprs.items.len; |
| 1610 | const array_data = try self.arena.alloc(usize, args.len); |
| 1611 | |
| 1612 | var array_type: ?DocData.Expr = null; |
| 1620 | 1613 | for (args) |arg, idx| { |
| 1621 | 1614 | const wr = try self.walkRef(file, parent_scope, arg, idx == 0); |
| 1615 | if (idx == 0) { |
| 1616 | array_type = wr.typeRef; |
| 1617 | } |
| 1622 | 1618 | |
| 1619 | const expr_index = self.exprs.items.len; |
| 1623 | 1620 | try self.exprs.append(self.arena, wr.expr); |
| 1621 | array_data[idx] = expr_index; |
| 1624 | 1622 | } |
| 1625 | 1623 | |
| 1626 | | return DocData.WalkResult{ |
| 1627 | | .typeRef = .{ .type = @enumToInt(Ref.void_type) }, |
| 1628 | | .expr = .{ .typeOf_peer = self.exprs.items[operand_index..] }, |
| 1624 | const type_slot_index = self.types.items.len; |
| 1625 | try self.types.append(self.arena, .{ |
| 1626 | .Array = .{ |
| 1627 | .len = .{ |
| 1628 | .int = .{ |
| 1629 | .value = args.len, |
| 1630 | .negated = false, |
| 1631 | }, |
| 1632 | }, |
| 1633 | .child = array_type.?, |
| 1634 | }, |
| 1635 | }); |
| 1636 | const result = DocData.WalkResult{ |
| 1637 | .typeRef = .{ .type = type_slot_index }, |
| 1638 | .expr = .{ .typeOf_peer = array_data }, |
| 1629 | 1639 | }; |
| 1640 | |
| 1641 | return result; |
| 1630 | 1642 | }, |
| 1631 | 1643 | .opaque_decl => return self.cteTodo("opaque {...}"), |
| 1632 | 1644 | .variable => { |
| ... | ... | @@ -2682,6 +2694,7 @@ fn analyzeFunction( |
| 2682 | 2694 | const last_instr_index = fn_info.ret_ty_body[fn_info.ret_ty_body.len - 1]; |
| 2683 | 2695 | const break_operand = data[last_instr_index].@"break".operand; |
| 2684 | 2696 | const wr = try self.walkRef(file, scope, break_operand, false); |
| 2697 | |
| 2685 | 2698 | break :blk wr; |
| 2686 | 2699 | }; |
| 2687 | 2700 | |