| ... | @@ -1021,6 +1021,7 @@ pub const DeclGen = struct { | ... | @@ -1021,6 +1021,7 @@ pub const DeclGen = struct { |
| 1021 | else => |tag| return self.todo("implement const of pointer type '{}' ({})", .{ tv.ty, tag }), | 1021 | else => |tag| return self.todo("implement const of pointer type '{}' ({})", .{ tv.ty, tag }), |
| 1022 | }, | 1022 | }, |
| 1023 | .Array => { | 1023 | .Array => { |
| | 1024 | const gpa = self.gpa; |
| 1024 | if (tv.val.castTag(.bytes)) |payload| { | 1025 | if (tv.val.castTag(.bytes)) |payload| { |
| 1025 | const zero_sentinel = if (tv.ty.sentinel()) |sentinel| blk: { | 1026 | const zero_sentinel = if (tv.ty.sentinel()) |sentinel| blk: { |
| 1026 | if (sentinel.tag() == .zero) break :blk true; | 1027 | if (sentinel.tag() == .zero) break :blk true; |
| ... | @@ -1034,7 +1035,6 @@ pub const DeclGen = struct { | ... | @@ -1034,7 +1035,6 @@ pub const DeclGen = struct { |
| 1034 | ); | 1035 | ); |
| 1035 | } | 1036 | } |
| 1036 | if (tv.val.castTag(.array)) |payload| { | 1037 | if (tv.val.castTag(.array)) |payload| { |
| 1037 | const gpa = self.gpa; | | |
| 1038 | const elem_ty = tv.ty.elemType(); | 1038 | const elem_ty = tv.ty.elemType(); |
| 1039 | const elem_vals = payload.data; | 1039 | const elem_vals = payload.data; |
| 1040 | const sento = tv.ty.sentinel(); | 1040 | const sento = tv.ty.sentinel(); |
| ... | @@ -1050,6 +1050,23 @@ pub const DeclGen = struct { | ... | @@ -1050,6 +1050,23 @@ pub const DeclGen = struct { |
| 1050 | @intCast(c_uint, llvm_elems.len), | 1050 | @intCast(c_uint, llvm_elems.len), |
| 1051 | ); | 1051 | ); |
| 1052 | } | 1052 | } |
| | 1053 | if (tv.val.castTag(.repeated)) |payload| { |
| | 1054 | const val = payload.data; |
| | 1055 | const elem_ty = tv.ty.elemType(); |
| | 1056 | const len = tv.ty.arrayLen(); |
| | 1057 | |
| | 1058 | const llvm_elems = try gpa.alloc(*const llvm.Value, len); |
| | 1059 | defer gpa.free(llvm_elems); |
| | 1060 | var i: u64 = 0; |
| | 1061 | while (i < len) : (i += 1) { |
| | 1062 | llvm_elems[i] = try self.genTypedValue(.{ .ty = elem_ty, .val = val }); |
| | 1063 | } |
| | 1064 | const llvm_elem_ty = try self.llvmType(elem_ty); |
| | 1065 | return llvm_elem_ty.constArray( |
| | 1066 | llvm_elems.ptr, |
| | 1067 | @intCast(c_uint, llvm_elems.len), |
| | 1068 | ); |
| | 1069 | } |
| 1053 | return self.todo("handle more array values", .{}); | 1070 | return self.todo("handle more array values", .{}); |
| 1054 | }, | 1071 | }, |
| 1055 | .Optional => { | 1072 | .Optional => { |