aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/value.zig b/src/value.zig
index 1836a14ce0..c043bc9364 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -768,7 +768,12 @@ pub const Value = extern union {
return allocator.dupe(u8, adjusted_bytes);
},
.enum_literal => return allocator.dupe(u8, val.castTag(.enum_literal).?.data),
- .repeated => @panic("TODO implement toAllocatedBytes for this Value tag"),
+ .repeated => {
+ const byte = @intCast(u8, val.castTag(.repeated).?.data.toUnsignedInt());
+ const result = try allocator.alloc(u8, @intCast(usize, ty.arrayLen()));
+ std.mem.set(u8, result, byte);
+ return result;
+ },
.decl_ref => {
const decl = val.castTag(.decl_ref).?.data;
const decl_val = try decl.value();
@@ -776,7 +781,15 @@ pub const Value = extern union {
},
.the_only_possible_value => return &[_]u8{},
.slice => return toAllocatedBytes(val.castTag(.slice).?.data.ptr, ty, allocator),
- else => unreachable,
+ else => {
+ const result = try allocator.alloc(u8, @intCast(usize, ty.arrayLen()));
+ var elem_value_buf: ElemValueBuffer = undefined;
+ for (result) |*elem, i| {
+ const elem_val = val.elemValueBuffer(i, &elem_value_buf);
+ elem.* = @intCast(u8, elem_val.toUnsignedInt());
+ }
+ return result;
+ },
}
}