cl: c.Func (llgo.funcAddr); demo: cppintf (how to use c++ interface)

This commit is contained in:
xushiwei
2024-06-21 23:44:56 +08:00
parent be0ce57375
commit bfa4e08a4e
11 changed files with 149 additions and 35 deletions

View File

@@ -524,12 +524,19 @@ func (p *context) compileInstrOrValue(b llssa.Builder, iv instrOrValue, asValue
ret = b.Slice(x, low, high, max)
case *ssa.MakeInterface:
if refs := *v.Referrers(); len(refs) == 1 {
if ref, ok := refs[0].(*ssa.Store); ok {
switch ref := refs[0].(type) {
case *ssa.Store:
if va, ok := ref.Addr.(*ssa.IndexAddr); ok {
if _, ok = p.isVArgs(va.X); ok { // varargs: this is a varargs store
return
}
}
case *ssa.Call:
if fn, ok := ref.Call.Value.(*ssa.Function); ok {
if _, _, ftype := p.funcOf(fn); ftype == llgoFuncAddr { // llgo.funcAddr
return
}
}
}
}
t := p.prog.Type(v.Type(), llssa.InGo)