compiler: Check trait object storage emission

90c7b202c750b97850523b67594041443bd0b628d84133d50f7d9b0d5db0199b
Alexis Sellier committed ago 1 parent 8841bacd
lib/std/lang/lower.rad +8 -0
4617 4617
    dataVal: il::Val,
4618 4618
    traitInfo: *unsafe resolver::TraitType,
4619 4619
    inst: &resolver::InstanceEntry
4620 4620
) -> il::Val throws (LowerError) where 'arena: 'phase, 'phase: 'function {
4621 4621
    let vName = vtableName(self.low, inst.moduleId, inst.concreteTypeName, traitInfo.name);
4622 +
    return emitTraitObject(self, dataVal, vName);
4623 +
}
4622 4624
4625 +
/// Store a trait object's data pointer and resolved v-table address.
4626 +
fn emitTraitObject 'arena 'phase 'function (
4627 +
    self: &mut FnLowerer 'arena 'phase 'function,
4628 +
    dataVal: il::Val,
4629 +
    vName: *[u8]
4630 +
) -> il::Val where 'arena: 'phase, 'phase: 'function {
4623 4631
    // Reserve space for the trait object on the stack.
4624 4632
    let slot = emitReserveLayout(self, resolver::Layout {
4625 4633
        size: resolver::PTR_SIZE * 2,
4626 4634
        alignment: resolver::PTR_SIZE,
4627 4635
    });