aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2023-06-25 18:50:58 -0400
committerAndrew Kelley <andrew@ziglang.org>2023-06-26 01:30:00 -0700
commitc036f83fa0f029e8e03e599f5b9e95cf98224a1c (patch)
treee187b0edca116f386992449434456193d083e671 /src/value.zig
parentcc2daae47e4fbb7d68e00211d509dd934d2e14b2 (diff)
downloadzig-c036f83fa0f029e8e03e599f5b9e95cf98224a1c.tar.gz
zig-c036f83fa0f029e8e03e599f5b9e95cf98224a1c.zip
Value: fix incorrect types returned from readFromMemory
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/value.zig b/src/value.zig
index 1c22717152..6b85ebd552 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -946,12 +946,24 @@ pub const Value = struct {
},
.Pointer => {
assert(!ty.isSlice(mod)); // No well defined layout.
- return readFromMemory(Type.usize, mod, buffer, arena);
+ const int_val = try readFromMemory(Type.usize, mod, buffer, arena);
+ return (try mod.intern(.{ .ptr = .{
+ .ty = ty.toIntern(),
+ .addr = .{ .int = int_val.toIntern() },
+ } })).toValue();
},
.Optional => {
assert(ty.isPtrLikeOptional(mod));
- const child = ty.optionalChild(mod);
- return readFromMemory(child, mod, buffer, arena);
+ const child_ty = ty.optionalChild(mod);
+ const child_val = try readFromMemory(child_ty, mod, buffer, arena);
+ return (try mod.intern(.{ .opt = .{
+ .ty = ty.toIntern(),
+ .val = switch (child_val.orderAgainstZero(mod)) {
+ .lt => unreachable,
+ .eq => .none,
+ .gt => child_val.toIntern(),
+ },
+ } })).toValue();
},
else => @panic("TODO implement readFromMemory for more types"),
}