diff options
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/llvm.zig | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index d223569d0f..98e12f5430 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1024,6 +1024,7 @@ pub const DeclGen = struct { else => |tag| return self.todo("implement const of pointer type '{}' ({})", .{ tv.ty, tag }), }, .Array => { + const gpa = self.gpa; if (tv.val.castTag(.bytes)) |payload| { const zero_sentinel = if (tv.ty.sentinel()) |sentinel| blk: { if (sentinel.tag() == .zero) break :blk true; @@ -1037,7 +1038,6 @@ pub const DeclGen = struct { ); } if (tv.val.castTag(.array)) |payload| { - const gpa = self.gpa; const elem_ty = tv.ty.elemType(); const elem_vals = payload.data; const sento = tv.ty.sentinel(); @@ -1053,6 +1053,23 @@ pub const DeclGen = struct { @intCast(c_uint, llvm_elems.len), ); } + if (tv.val.castTag(.repeated)) |payload| { + const val = payload.data; + const elem_ty = tv.ty.elemType(); + const len = tv.ty.arrayLen(); + + const llvm_elems = try gpa.alloc(*const llvm.Value, len); + defer gpa.free(llvm_elems); + var i: u64 = 0; + while (i < len) : (i += 1) { + llvm_elems[i] = try self.genTypedValue(.{ .ty = elem_ty, .val = val }); + } + const llvm_elem_ty = try self.llvmType(elem_ty); + return llvm_elem_ty.constArray( + llvm_elems.ptr, + @intCast(c_uint, llvm_elems.len), + ); + } return self.todo("handle more array values", .{}); }, .Optional => { |
