| ... | ... | @@ -425,14 +425,6 @@ pub const Decl = struct { |
| 425 | 425 | return @as(i32, @bitCast(node_index)) - @as(i32, @bitCast(decl.src_node)); |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | | pub fn tokSrcLoc(decl: Decl, token_index: Ast.TokenIndex) LazySrcLoc { |
| 429 | | return .{ .token_offset = token_index - decl.srcToken() }; |
| 430 | | } |
| 431 | | |
| 432 | | pub fn nodeSrcLoc(decl: Decl, node_index: Ast.Node.Index) LazySrcLoc { |
| 433 | | return LazySrcLoc.nodeOffset(decl.nodeIndexToRelative(node_index)); |
| 434 | | } |
| 435 | | |
| 436 | 428 | pub fn srcLoc(decl: Decl, zcu: *Zcu) SrcLoc { |
| 437 | 429 | return decl.nodeOffsetSrcLoc(0, zcu); |
| 438 | 430 | } |
| ... | ... | @@ -445,16 +437,6 @@ pub const Decl = struct { |
| 445 | 437 | }; |
| 446 | 438 | } |
| 447 | 439 | |
| 448 | | pub fn srcToken(decl: Decl, zcu: *Zcu) Ast.TokenIndex { |
| 449 | | const tree = &decl.getFileScope(zcu).tree; |
| 450 | | return tree.firstToken(decl.src_node); |
| 451 | | } |
| 452 | | |
| 453 | | pub fn srcByteOffset(decl: Decl, zcu: *Zcu) u32 { |
| 454 | | const tree = &decl.getFileScope(zcu).tree; |
| 455 | | return tree.tokens.items(.start)[decl.srcToken()]; |
| 456 | | } |
| 457 | | |
| 458 | 440 | pub fn renderFullyQualifiedName(decl: Decl, zcu: *Zcu, writer: anytype) !void { |
| 459 | 441 | if (decl.name_fully_qualified) { |
| 460 | 442 | try writer.print("{}", .{decl.name.fmt(&zcu.intern_pool)}); |
| ... | ... | @@ -486,22 +468,6 @@ pub const Decl = struct { |
| 486 | 468 | return decl.val; |
| 487 | 469 | } |
| 488 | 470 | |
| 489 | | /// If the Decl owns its value and it is a struct, return it, |
| 490 | | /// otherwise null. |
| 491 | | pub fn getOwnedStruct(decl: Decl, zcu: *Zcu) ?InternPool.Key.StructType { |
| 492 | | if (!decl.owns_tv) return null; |
| 493 | | if (decl.val.ip_index == .none) return null; |
| 494 | | return zcu.typeToStruct(decl.val.toType()); |
| 495 | | } |
| 496 | | |
| 497 | | /// If the Decl owns its value and it is a union, return it, |
| 498 | | /// otherwise null. |
| 499 | | pub fn getOwnedUnion(decl: Decl, zcu: *Zcu) ?InternPool.LoadedUnionType { |
| 500 | | if (!decl.owns_tv) return null; |
| 501 | | if (decl.val.ip_index == .none) return null; |
| 502 | | return zcu.typeToUnion(decl.val.toType()); |
| 503 | | } |
| 504 | | |
| 505 | 471 | pub fn getOwnedFunction(decl: Decl, zcu: *Zcu) ?InternPool.Key.Func { |
| 506 | 472 | const i = decl.getOwnedFunctionIndex(); |
| 507 | 473 | if (i == .none) return null; |
| ... | ... | @@ -4427,22 +4393,6 @@ fn scanDecl(iter: *ScanDeclIter, decl_inst: Zir.Inst.Index) Allocator.Error!void |
| 4427 | 4393 | } |
| 4428 | 4394 | } |
| 4429 | 4395 | |
| 4430 | | /// This function is exclusively called for anonymous decls. |
| 4431 | | /// All resources referenced by anonymous decls are owned by InternPool |
| 4432 | | /// so there is no cleanup to do here. |
| 4433 | | pub fn deleteUnusedDecl(mod: *Module, decl_index: Decl.Index) void { |
| 4434 | | const gpa = mod.gpa; |
| 4435 | | const ip = &mod.intern_pool; |
| 4436 | | |
| 4437 | | ip.destroyDecl(gpa, decl_index); |
| 4438 | | |
| 4439 | | if (mod.emit_h) |mod_emit_h| { |
| 4440 | | const decl_emit_h = mod_emit_h.declPtr(decl_index); |
| 4441 | | decl_emit_h.fwd_decl.deinit(gpa); |
| 4442 | | decl_emit_h.* = undefined; |
| 4443 | | } |
| 4444 | | } |
| 4445 | | |
| 4446 | 4396 | /// Cancel the creation of an anon decl and delete any references to it. |
| 4447 | 4397 | /// If other decls depend on this decl, they must be aborted first. |
| 4448 | 4398 | pub fn abortAnonDecl(mod: *Module, decl_index: Decl.Index) void { |