| ... | ... | @@ -843,7 +843,7 @@ fn walkInstruction( |
| 843 | 843 | }); |
| 844 | 844 | |
| 845 | 845 | return DocData.WalkResult{ |
| 846 | | .typeRef = .{ .type = @enumToInt(Ref.type_type) }, |
| 846 | .typeRef = .{ .type = elem_type_ref.expr.type }, |
| 847 | 847 | .expr = .{ .type = type_slot_index }, |
| 848 | 848 | }; |
| 849 | 849 | }, |
| ... | ... | @@ -1040,6 +1040,94 @@ fn walkInstruction( |
| 1040 | 1040 | .expr = .{ .array = array_data }, |
| 1041 | 1041 | }; |
| 1042 | 1042 | }, |
| 1043 | .array_init_ref => { |
| 1044 | const pl_node = data[inst_index].pl_node; |
| 1045 | const extra = file.zir.extraData(Zir.Inst.MultiOp, pl_node.payload_index); |
| 1046 | const operands = file.zir.refSlice(extra.end, extra.data.operands_len); |
| 1047 | const array_data = try self.arena.alloc(usize, operands.len); |
| 1048 | |
| 1049 | var array_type: ?DocData.Expr = null; |
| 1050 | for (operands) |op, idx| { |
| 1051 | const wr = try self.walkRef(file, parent_scope, op, idx == 0); |
| 1052 | if (idx == 0) { |
| 1053 | array_type = wr.typeRef; |
| 1054 | } |
| 1055 | array_data[idx] = wr.expr.as.exprArg; |
| 1056 | } |
| 1057 | |
| 1058 | const type_slot_index = self.types.items.len; |
| 1059 | try self.types.append(self.arena, .{ .Pointer = .{ |
| 1060 | .size = .One, |
| 1061 | .child = array_type.?, |
| 1062 | } }); |
| 1063 | |
| 1064 | return DocData.WalkResult{ |
| 1065 | .typeRef = .{ .type = type_slot_index }, |
| 1066 | .expr = .{ .array = array_data }, |
| 1067 | }; |
| 1068 | }, |
| 1069 | .array_init_sent_ref => { |
| 1070 | const pl_node = data[inst_index].pl_node; |
| 1071 | const extra = file.zir.extraData(Zir.Inst.MultiOp, pl_node.payload_index); |
| 1072 | // the sentinel terminator are calculated at compile time |
| 1073 | // (extra.data.operands_len - 1) is to not account for that |
| 1074 | const operands = file.zir.refSlice(extra.end, extra.data.operands_len - 1); |
| 1075 | const array_data = try self.arena.alloc(usize, operands.len); |
| 1076 | |
| 1077 | var array_type: ?DocData.Expr = null; |
| 1078 | for (operands) |op, idx| { |
| 1079 | const wr = try self.walkRef(file, parent_scope, op, idx == 0); |
| 1080 | if (idx == 0) { |
| 1081 | array_type = wr.typeRef; |
| 1082 | } |
| 1083 | array_data[idx] = wr.expr.as.exprArg; |
| 1084 | } |
| 1085 | |
| 1086 | const type_slot_index = self.types.items.len; |
| 1087 | try self.types.append(self.arena, .{ |
| 1088 | .Array = .{ .len = .{ |
| 1089 | .int = .{ |
| 1090 | .value = operands.len, |
| 1091 | .negated = false, |
| 1092 | }, |
| 1093 | }, .child = array_type.?, .sentinel = 0 }, |
| 1094 | }); |
| 1095 | |
| 1096 | return DocData.WalkResult{ |
| 1097 | .typeRef = .{ .type = type_slot_index }, |
| 1098 | .expr = .{ .array = array_data }, |
| 1099 | }; |
| 1100 | }, |
| 1101 | .array_init_anon_ref => { |
| 1102 | const pl_node = data[inst_index].pl_node; |
| 1103 | const extra = file.zir.extraData(Zir.Inst.MultiOp, pl_node.payload_index); |
| 1104 | const operands = file.zir.refSlice(extra.end, extra.data.operands_len); |
| 1105 | const array_data = try self.arena.alloc(usize, operands.len); |
| 1106 | |
| 1107 | var array_type: ?DocData.Expr = null; |
| 1108 | for (operands) |op, idx| { |
| 1109 | const wr = try self.walkRef(file, parent_scope, op, idx == 0); |
| 1110 | if (idx == 0) { |
| 1111 | array_type = wr.typeRef; |
| 1112 | } |
| 1113 | array_data[idx] = wr.expr.int.value; |
| 1114 | } |
| 1115 | |
| 1116 | const type_slot_index = self.types.items.len; |
| 1117 | try self.types.append(self.arena, .{ |
| 1118 | .Array = .{ .len = .{ |
| 1119 | .int = .{ |
| 1120 | .value = operands.len, |
| 1121 | .negated = false, |
| 1122 | }, |
| 1123 | }, .child = array_type.? }, |
| 1124 | }); |
| 1125 | |
| 1126 | return DocData.WalkResult{ |
| 1127 | .typeRef = .{ .type = type_slot_index }, |
| 1128 | .expr = .{ .array = array_data }, |
| 1129 | }; |
| 1130 | }, |
| 1043 | 1131 | .float => { |
| 1044 | 1132 | const float = data[inst_index].float; |
| 1045 | 1133 | return DocData.WalkResult{ |
| ... | ... | @@ -1116,6 +1204,7 @@ fn walkInstruction( |
| 1116 | 1204 | extra.data.operand, |
| 1117 | 1205 | false, |
| 1118 | 1206 | ); |
| 1207 | |
| 1119 | 1208 | const operand_idx = self.exprs.items.len; |
| 1120 | 1209 | try self.exprs.append(self.arena, operand.expr); |
| 1121 | 1210 | |