ssa: interface equal

This commit is contained in:
visualfc
2024-06-11 10:24:30 +08:00
parent 439a69f413
commit bdf1c275c4
4 changed files with 150 additions and 6 deletions

View File

@@ -118,14 +118,12 @@ func (b Builder) abiMethods(t *types.Named) (ret, pret int) {
}
// Method{name string, typ *FuncType, ifn, tfn abi.Text}
func (b Builder) abiMethodOf(m *types.Func /*, bg Background = InGo */) (mthd, ptrMthd Expr) {
func (b Builder) abiMethodOf(mPkg *types.Package, mName string, mSig *types.Signature /*, bg Background = InGo */) (mthd, ptrMthd Expr) {
prog := b.Prog
mPkg, mName := m.Pkg(), m.Name()
mSig := m.Type().(*types.Signature)
name := b.Str(mName).impl
if !token.IsExported(mName) {
name = b.Str(abi.FullName(mPkg, m.Name())).impl
name = b.Str(abi.FullName(mPkg, mName)).impl
}
abiSigGo := types.NewSignatureType(nil, nil, nil, mSig.Params(), mSig.Results(), mSig.Variadic())
abiSig := prog.FuncDecl(abiSigGo, InGo).raw.Type
@@ -217,8 +215,8 @@ func (b Builder) abiInitNamed(ret Expr, t *types.Named) func() Expr {
var mthds []Expr
var ptrMthds = make([]Expr, 0, n)
for i := 0; i < n; i++ {
m := mset[i].Obj().(*types.Func)
mthd, ptrMthd := b.abiMethodOf(m)
sel := mset[i]
mthd, ptrMthd := b.abiMethodOf(sel.Obj().Pkg(), sel.Obj().Name(), sel.Type().(*types.Signature))
if !mthd.IsNil() {
mthds = append(mthds, mthd)
}