aboutsummaryrefslogtreecommitdiff
path: root/src/TypedValue.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-06-12 01:00:33 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-06-12 01:33:56 -0700
commite64d5a0753dd31702032a458d95c327005c09f85 (patch)
tree16103f259ec3b7382ca8842025511b6989b62a1e /src/TypedValue.zig
parentc29746aa553a72fe2ef2d414c1b616ee2a94eab4 (diff)
downloadzig-e64d5a0753dd31702032a458d95c327005c09f85.tar.gz
zig-e64d5a0753dd31702032a458d95c327005c09f85.zip
Sema: rework beginComptimePtrMutation
This comment is now deleted because the task is completed in this commit: ``` // TODO: Update this to behave like `beginComptimePtrLoad` and properly check/use // `container_ty` and `array_ty`, instead of trusting that the parent decl type // matches the type used to derive the elem_ptr/field_ptr/etc. // // This is needed because the types will not match if the pointer we're mutating // through is reinterpreting comptime memory. ``` The main strategy is to change the ComptimePtrMutationKit struct so that instead of `val: *Value` it now returns a tagged union which can be one of three possibilities: * The pointer type matches the actual comptime Value so a direct modification is possible. Before this commit, the implementation incorrectly assumed this was always the case. * In the case of needing to write through a reinterpreted pointer, a mutable base Value pointer is provided along with a byte offset pointing to the element value in virtual memory. * Otherwise, it means a compile error must be emitted because one or both of the types (the owner of the value, or the pointer type being used to write through) do not have a well-defined memory layout. After calling beginComptimePtrMutation, the one callsite now switches on this tagged union and does the appropriate thing. The main new logic is for the second case, which involves pointer reinterpretation, which now takes this strategy: 1. write the base value to a memory buffer. 2. perform the pointer store at the proper byte offset, thereby modifying a subset of the buffer. 3. read the base value from the memory buffer, overwriting the old base value.
Diffstat (limited to 'src/TypedValue.zig')
0 files changed, 0 insertions, 0 deletions