| ... | ... | @@ -534,7 +534,14 @@ pub const DeclGen = struct { |
| 534 | 534 | .Bool => return self.context.intType(1), |
| 535 | 535 | .Pointer => { |
| 536 | 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 | 545 | } else { |
| 539 | 546 | const elem_type = try self.llvmType(t.elemType()); |
| 540 | 547 | return elem_type.pointerType(0); |
| ... | ... | @@ -549,7 +556,7 @@ pub const DeclGen = struct { |
| 549 | 556 | var buf: Type.Payload.ElemType = undefined; |
| 550 | 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 | 560 | try self.llvmType(child_type), |
| 554 | 561 | self.context.intType(1), |
| 555 | 562 | }; |
| ... | ... | @@ -559,8 +566,16 @@ pub const DeclGen = struct { |
| 559 | 566 | } |
| 560 | 567 | }, |
| 561 | 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 | 574 | return self.todo("implement llvmType for error unions", .{}); |
| 563 | 575 | }, |
| 576 | .ErrorSet => { |
| 577 | return self.context.intType(16); |
| 578 | }, |
| 564 | 579 | .ComptimeInt => unreachable, |
| 565 | 580 | .ComptimeFloat => unreachable, |
| 566 | 581 | .Type => unreachable, |
| ... | ... | @@ -572,7 +587,6 @@ pub const DeclGen = struct { |
| 572 | 587 | |
| 573 | 588 | .Float, |
| 574 | 589 | .Struct, |
| 575 | | .ErrorSet, |
| 576 | 590 | .Enum, |
| 577 | 591 | .Union, |
| 578 | 592 | .Fn, |