| ... | @@ -1655,30 +1655,6 @@ pub const Value = struct { | ... | @@ -1655,30 +1655,6 @@ pub const Value = struct { |
| 1655 | }; | 1655 | }; |
| 1656 | } | 1656 | } |
| 1657 | | 1657 | |
| 1658 | /// Returns true if a Value is backed by a variable | | |
| 1659 | pub fn isVariable(val: Value, mod: *Module) bool { | | |
| 1660 | return val.ip_index != .none and switch (mod.intern_pool.indexToKey(val.toIntern())) { | | |
| 1661 | .variable => true, | | |
| 1662 | .ptr => |ptr| switch (ptr.addr) { | | |
| 1663 | .decl => |decl_index| { | | |
| 1664 | const decl = mod.declPtr(decl_index); | | |
| 1665 | assert(decl.has_tv); | | |
| 1666 | return decl.val.isVariable(mod); | | |
| 1667 | }, | | |
| 1668 | .mut_decl => |mut_decl| { | | |
| 1669 | const decl = mod.declPtr(mut_decl.decl); | | |
| 1670 | assert(decl.has_tv); | | |
| 1671 | return decl.val.isVariable(mod); | | |
| 1672 | }, | | |
| 1673 | .int => false, | | |
| 1674 | .eu_payload, .opt_payload => |base_ptr| base_ptr.toValue().isVariable(mod), | | |
| 1675 | .comptime_field => |comptime_field| comptime_field.toValue().isVariable(mod), | | |
| 1676 | .elem, .field => |base_index| base_index.base.toValue().isVariable(mod), | | |
| 1677 | }, | | |
| 1678 | else => false, | | |
| 1679 | }; | | |
| 1680 | } | | |
| 1681 | | | |
| 1682 | pub fn isPtrToThreadLocal(val: Value, mod: *Module) bool { | 1658 | pub fn isPtrToThreadLocal(val: Value, mod: *Module) bool { |
| 1683 | const backing_decl = mod.intern_pool.getBackingDecl(val.toIntern()).unwrap() orelse return false; | 1659 | const backing_decl = mod.intern_pool.getBackingDecl(val.toIntern()).unwrap() orelse return false; |
| 1684 | const variable = mod.declPtr(backing_decl).getOwnedVariable(mod) orelse return false; | 1660 | const variable = mod.declPtr(backing_decl).getOwnedVariable(mod) orelse return false; |