| ... | ... | @@ -1238,9 +1238,24 @@ pub const Value = extern union { |
| 1238 | 1238 | const b_field_index = b.castTag(.enum_field_index).?.data; |
| 1239 | 1239 | return a_field_index == b_field_index; |
| 1240 | 1240 | }, |
| 1241 | .elem_ptr => @panic("TODO: Implement more pointer eql cases"), |
| 1242 | .field_ptr => @panic("TODO: Implement more pointer eql cases"), |
| 1243 | .eu_payload_ptr => @panic("TODO: Implement more pointer eql cases"), |
| 1244 | .opt_payload_ptr => @panic("TODO: Implement more pointer eql cases"), |
| 1241 | 1245 | else => {}, |
| 1242 | 1246 | } |
| 1243 | 1247 | } |
| 1248 | |
| 1249 | if (a.pointerDecl()) |a_decl| { |
| 1250 | if (b.pointerDecl()) |b_decl| { |
| 1251 | return a_decl == b_decl; |
| 1252 | } else { |
| 1253 | return false; |
| 1254 | } |
| 1255 | } else if (b.pointerDecl()) |_| { |
| 1256 | return false; |
| 1257 | } |
| 1258 | |
| 1244 | 1259 | if (ty.zigTypeTag() == .Type) { |
| 1245 | 1260 | var buf_a: ToTypeBuffer = undefined; |
| 1246 | 1261 | var buf_b: ToTypeBuffer = undefined; |
| ... | ... | @@ -1285,8 +1300,28 @@ pub const Value = extern union { |
| 1285 | 1300 | const float = val.toFloat(f128); |
| 1286 | 1301 | std.hash.autoHash(hasher, @bitCast(u128, float)); |
| 1287 | 1302 | }, |
| 1288 | | .Pointer => { |
| 1289 | | @panic("TODO implement hashing pointer values"); |
| 1303 | .Pointer => switch (val.tag()) { |
| 1304 | .decl_ref_mut, |
| 1305 | .extern_fn, |
| 1306 | .decl_ref, |
| 1307 | .function, |
| 1308 | .variable, |
| 1309 | => std.hash.autoHash(hasher, val.pointerDecl().?), |
| 1310 | |
| 1311 | .elem_ptr => @panic("TODO: Implement more pointer hashing cases"), |
| 1312 | .field_ptr => @panic("TODO: Implement more pointer hashing cases"), |
| 1313 | .eu_payload_ptr => @panic("TODO: Implement more pointer hashing cases"), |
| 1314 | .opt_payload_ptr => @panic("TODO: Implement more pointer hashing cases"), |
| 1315 | |
| 1316 | .zero, |
| 1317 | .one, |
| 1318 | .int_u64, |
| 1319 | .int_i64, |
| 1320 | .int_big_positive, |
| 1321 | .int_big_negative, |
| 1322 | => @panic("TODO: Implement pointer hashing for int pointers"), |
| 1323 | |
| 1324 | else => unreachable, |
| 1290 | 1325 | }, |
| 1291 | 1326 | .Array, .Vector => { |
| 1292 | 1327 | @panic("TODO implement hashing array/vector values"); |
| ... | ... | @@ -1432,6 +1467,19 @@ pub const Value = extern union { |
| 1432 | 1467 | return sub_val; |
| 1433 | 1468 | } |
| 1434 | 1469 | |
| 1470 | /// Gets the decl referenced by this pointer. If the pointer does not point |
| 1471 | /// to a decl, or if it points to some part of a decl (like field_ptr or element_ptr), |
| 1472 | /// this function returns null. |
| 1473 | pub fn pointerDecl(self: Value) ?*Module.Decl { |
| 1474 | return switch (self.tag()) { |
| 1475 | .decl_ref_mut => self.castTag(.decl_ref_mut).?.data.decl, |
| 1476 | .extern_fn, .decl_ref => self.cast(Payload.Decl).?.data, |
| 1477 | .function => self.castTag(.function).?.data.owner_decl, |
| 1478 | .variable => self.castTag(.variable).?.data.owner_decl, |
| 1479 | else => null, |
| 1480 | }; |
| 1481 | } |
| 1482 | |
| 1435 | 1483 | pub fn sliceLen(val: Value) u64 { |
| 1436 | 1484 | return switch (val.tag()) { |
| 1437 | 1485 | .empty_array => 0, |