diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2024-03-25 23:08:59 +0000 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2024-03-26 13:48:06 +0000 |
| commit | 5ec6e3036b2772e6efc08726b22c560dedd556bc (patch) | |
| tree | 9c4625688ff540c0cd9bece36bef96276da08842 /src/Value.zig | |
| parent | c6f3e9d79cf849623e6c4f25e02e17cdfab07b7c (diff) | |
| download | zig-5ec6e3036b2772e6efc08726b22c560dedd556bc.tar.gz zig-5ec6e3036b2772e6efc08726b22c560dedd556bc.zip | |
Sema: introduce separate `MutableValue` representation for comptime-mutable memory
Perhaps someday, we will make Sema operate on mutable values more
generally. For now, it makes sense to split out this representation,
since it is only used in comptime pointer accesses.
There are some currently unused methods on `MutableValue` which will
be used once I rewrite the comptime pointer access logic to be less
terrible.
The commit following this one will - at long last - delete the legacy
Value representation
Diffstat (limited to 'src/Value.zig')
| -rw-r--r-- | src/Value.zig | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Value.zig b/src/Value.zig index c220f6d0d9..af24d68d7c 100644 --- a/src/Value.zig +++ b/src/Value.zig @@ -1627,7 +1627,9 @@ pub fn maybeElemValueFull(val: Value, sema: ?*Sema, mod: *Module, index: usize) .ptr => |ptr| switch (ptr.addr) { .decl => |decl| mod.declPtr(decl).val.maybeElemValueFull(sema, mod, index), .anon_decl => |anon_decl| Value.fromInterned(anon_decl.val).maybeElemValueFull(sema, mod, index), - .comptime_alloc => |idx| if (sema) |s| s.getComptimeAlloc(idx).val.maybeElemValueFull(sema, mod, index) else null, + .comptime_alloc => |idx| if (sema) |s| Value.fromInterned( + try s.getComptimeAlloc(idx).val.intern(mod, s.arena), + ).maybeElemValueFull(sema, mod, index) else null, .int, .eu_payload => null, .opt_payload => |base| Value.fromInterned(base).maybeElemValueFull(sema, mod, index), .comptime_field => |field_val| Value.fromInterned(field_val).maybeElemValueFull(sema, mod, index), @@ -1697,7 +1699,9 @@ pub fn sliceArray( else => switch (mod.intern_pool.indexToKey(val.toIntern())) { .ptr => |ptr| switch (ptr.addr) { .decl => |decl| try mod.declPtr(decl).val.sliceArray(sema, start, end), - .comptime_alloc => |idx| sema.getComptimeAlloc(idx).val.sliceArray(sema, start, end), + .comptime_alloc => |idx| try Value.fromInterned( + try sema.getComptimeAlloc(idx).val.intern(mod, sema.arena), + ).sliceArray(sema, start, end), .comptime_field => |comptime_field| Value.fromInterned(comptime_field) .sliceArray(sema, start, end), .elem => |elem| Value.fromInterned(elem.base) |
