| ... | @@ -534,7 +534,14 @@ pub const DeclGen = struct { | ... | @@ -534,7 +534,14 @@ pub const DeclGen = struct { |
| 534 | .Bool => return self.context.intType(1), | 534 | .Bool => return self.context.intType(1), |
| 535 | .Pointer => { | 535 | .Pointer => { |
| 536 | if (t.isSlice()) { | 536 | if (t.isSlice()) { |
| 537 | return self.todo("implement slices", .{}); | 537 | var buf: Type.Payload.ElemType = undefined; |
| | 538 | const ptr_type = t.slicePtrFieldType(&buf); |
| | 539 | |
| | 540 | const fields: [2]*const llvm.Type = .{ |
| | 541 | try self.llvmType(ptr_type), |
| | 542 | try self.llvmType(Type.initTag(.usize)), |
| | 543 | }; |
| | 544 | return self.context.structType(&fields, 2, .False); |
| 538 | } else { | 545 | } else { |
| 539 | const elem_type = try self.llvmType(t.elemType()); | 546 | const elem_type = try self.llvmType(t.elemType()); |
| 540 | return elem_type.pointerType(0); | 547 | return elem_type.pointerType(0); |
| ... | @@ -549,7 +556,7 @@ pub const DeclGen = struct { | ... | @@ -549,7 +556,7 @@ pub const DeclGen = struct { |
| 549 | var buf: Type.Payload.ElemType = undefined; | 556 | var buf: Type.Payload.ElemType = undefined; |
| 550 | const child_type = t.optionalChild(&buf); | 557 | const child_type = t.optionalChild(&buf); |
| 551 | | 558 | |
| 552 | var optional_types: [2]*const llvm.Type = .{ | 559 | const optional_types: [2]*const llvm.Type = .{ |
| 553 | try self.llvmType(child_type), | 560 | try self.llvmType(child_type), |
| 554 | self.context.intType(1), | 561 | self.context.intType(1), |
| 555 | }; | 562 | }; |
| ... | @@ -559,8 +566,16 @@ pub const DeclGen = struct { | ... | @@ -559,8 +566,16 @@ pub const DeclGen = struct { |
| 559 | } | 566 | } |
| 560 | }, | 567 | }, |
| 561 | .ErrorUnion => { | 568 | .ErrorUnion => { |
| | 569 | const error_type = t.errorUnionSet(); |
| | 570 | const payload_type = t.errorUnionPayload(); |
| | 571 | if (!payload_type.hasCodeGenBits()) { |
| | 572 | return self.llvmType(error_type); |
| | 573 | } |
| 562 | return self.todo("implement llvmType for error unions", .{}); | 574 | return self.todo("implement llvmType for error unions", .{}); |
| 563 | }, | 575 | }, |
| | 576 | .ErrorSet => { |
| | 577 | return self.context.intType(16); |
| | 578 | }, |
| 564 | .ComptimeInt => unreachable, | 579 | .ComptimeInt => unreachable, |
| 565 | .ComptimeFloat => unreachable, | 580 | .ComptimeFloat => unreachable, |
| 566 | .Type => unreachable, | 581 | .Type => unreachable, |
| ... | @@ -572,7 +587,6 @@ pub const DeclGen = struct { | ... | @@ -572,7 +587,6 @@ pub const DeclGen = struct { |
| 572 | | 587 | |
| 573 | .Float, | 588 | .Float, |
| 574 | .Struct, | 589 | .Struct, |
| 575 | .ErrorSet, | | |
| 576 | .Enum, | 590 | .Enum, |
| 577 | .Union, | 591 | .Union, |
| 578 | .Fn, | 592 | .Fn, |