ssa: MakeInterface check abi.KindDirectIface

This commit is contained in:
visualfc
2024-06-02 19:56:37 +08:00
parent 73d6bd8400
commit 7596658e6c
13 changed files with 1761 additions and 712 deletions

View File

@@ -73,7 +73,8 @@ func (b Builder) Imethod(intf Expr, method *types.Func) Expr {
itab := Expr{b.faceItab(impl), prog.VoidPtrPtr()}
pfn := b.Advance(itab, prog.IntVal(uint64(i+3), prog.Int()))
fn := b.Load(pfn)
ret := b.aggregateValue(tclosure, fn.impl, b.faceData(impl))
data := b.InlineCall(b.Pkg.rtFunc("IfaceData"), intf)
ret := b.aggregateValue(tclosure, fn.impl, data.impl)
return ret
}
@@ -125,10 +126,16 @@ func (b Builder) MakeInterface(tinter Type, x Expr) (ret Expr) {
default:
panic("todo")
}
// abi.Type.Kind_ |= abi.KindDirectIface
pkind := b.FieldAddr(tabi, 6)
b.Store(pkind, b.BinOp(token.OR, b.Load(pkind), Expr{prog.IntVal(kindDirectIface, prog.Byte()).impl, prog.Byte()}))
data := llvm.CreateIntToPtr(b.impl, u, prog.tyVoidPtr())
return Expr{b.unsafeInterface(rawIntf, tabi, data), tinter}
}
// abi.KindDirectIface
const kindDirectIface = 1 << 5
func (b Builder) valFromData(typ Type, data llvm.Value) Expr {
prog := b.Prog
kind, real, lvl := abi.DataKindOf(typ.raw.Type, 0, prog.is32Bits)