| ... | @@ -575,6 +575,7 @@ const DocData = struct { | ... | @@ -575,6 +575,7 @@ const DocData = struct { |
| 575 | call: usize, // index in `calls` | 575 | call: usize, // index in `calls` |
| 576 | enumLiteral: []const u8, // direct value | 576 | enumLiteral: []const u8, // direct value |
| 577 | typeOf: usize, // index in `exprs` | 577 | typeOf: usize, // index in `exprs` |
| | 578 | typeOf_peer: []Expr, |
| 578 | as: As, | 579 | as: As, |
| 579 | sizeOf: usize, // index in `exprs` | 580 | sizeOf: usize, // index in `exprs` |
| 580 | compileError: []const u8, | 581 | compileError: []const u8, |
| ... | @@ -641,6 +642,14 @@ const DocData = struct { | ... | @@ -641,6 +642,14 @@ const DocData = struct { |
| 641 | options, | 642 | options, |
| 642 | w, | 643 | w, |
| 643 | ), | 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 | }, |
| 644 | .refPath => |v| { | 653 | .refPath => |v| { |
| 645 | try w.print("{{ \"refPath\": [", .{}); | 654 | try w.print("{{ \"refPath\": [", .{}); |
| 646 | for (v) |c, i| { | 655 | for (v) |c, i| { |
| ... | @@ -1509,7 +1518,8 @@ fn walkInstruction( | ... | @@ -1509,7 +1518,8 @@ fn walkInstruction( |
| 1509 | .expr = .{ .type = type_slot_index }, | 1518 | .expr = .{ .type = type_slot_index }, |
| 1510 | }; | 1519 | }; |
| 1511 | }, | 1520 | }, |
| 1512 | .param_anytype => { | 1521 | .param_anytype, .param_anytype_comptime => { |
| | 1522 | // @check if .param_anytype_comptime can be here |
| 1513 | // Analysis of anytype function params happens in `.func`. | 1523 | // Analysis of anytype function params happens in `.func`. |
| 1514 | // This switch case handles the case where an expression depends | 1524 | // This switch case handles the case where an expression depends |
| 1515 | // on an anytype field. E.g.: `fn foo(bar: anytype) @TypeOf(bar)`. | 1525 | // on an anytype field. E.g.: `fn foo(bar: anytype) @TypeOf(bar)`. |
| ... | @@ -1527,6 +1537,13 @@ fn walkInstruction( | ... | @@ -1527,6 +1537,13 @@ fn walkInstruction( |
| 1527 | const pl_tok = data[inst_index].pl_tok; | 1537 | const pl_tok = data[inst_index].pl_tok; |
| 1528 | const extra = file.zir.extraData(Zir.Inst.Param, pl_tok.payload_index); | 1538 | const extra = file.zir.extraData(Zir.Inst.Param, pl_tok.payload_index); |
| 1529 | const name = file.zir.nullTerminatedString(extra.data.name); | 1539 | const name = file.zir.nullTerminatedString(extra.data.name); |
| | 1540 | |
| | 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 | |
| 1530 | const cte_slot_index = self.comptime_exprs.items.len; | 1547 | const cte_slot_index = self.comptime_exprs.items.len; |
| 1531 | try self.comptime_exprs.append(self.arena, .{ | 1548 | try self.comptime_exprs.append(self.arena, .{ |
| 1532 | .code = name, | 1549 | .code = name, |
| ... | @@ -1595,7 +1612,22 @@ fn walkInstruction( | ... | @@ -1595,7 +1612,22 @@ fn walkInstruction( |
| 1595 | ); | 1612 | ); |
| 1596 | return self.cteTodo(@tagName(extended.opcode)); | 1613 | return self.cteTodo(@tagName(extended.opcode)); |
| 1597 | }, | 1614 | }, |
| | 1615 | .typeof_peer => { |
| | 1616 | // Zir says it's a NodeMultiOp but in this case it's TypeOfPeer |
| | 1617 | const extra = file.zir.extraData(Zir.Inst.TypeOfPeer, extended.operand); |
| | 1618 | const args = file.zir.refSlice(extra.end, extended.small); |
| | 1619 | const operand_index = self.exprs.items.len; |
| | 1620 | for (args) |arg, idx| { |
| | 1621 | const wr = try self.walkRef(file, parent_scope, arg, idx == 0); |
| | 1622 | |
| | 1623 | try self.exprs.append(self.arena, wr.expr); |
| | 1624 | } |
| 1598 | | 1625 | |
| | 1626 | return DocData.WalkResult{ |
| | 1627 | .typeRef = .{ .type = @enumToInt(Ref.void_type) }, |
| | 1628 | .expr = .{ .typeOf_peer = self.exprs.items[operand_index..] }, |
| | 1629 | }; |
| | 1630 | }, |
| 1599 | .opaque_decl => return self.cteTodo("opaque {...}"), | 1631 | .opaque_decl => return self.cteTodo("opaque {...}"), |
| 1600 | .variable => { | 1632 | .variable => { |
| 1601 | const small = @bitCast(Zir.Inst.ExtendedVar.Small, extended.small); | 1633 | const small = @bitCast(Zir.Inst.ExtendedVar.Small, extended.small); |