ssa: closure use specific struct field name { $f ftype, $data unsafe.pointer }
This commit is contained in:
@@ -106,9 +106,6 @@ func (b Builder) MakeInterface(tinter Type, x Expr) (ret Expr) {
|
||||
prog := b.Prog
|
||||
typ := x.Type
|
||||
tabi := b.abiType(typ.raw.Type)
|
||||
if x.kind == vkClosure {
|
||||
b.InlineCall(b.Pkg.rtFunc("SetClosure"), tabi)
|
||||
}
|
||||
kind, _, lvl := abi.DataKindOf(typ.raw.Type, 0, prog.is32Bits)
|
||||
switch kind {
|
||||
case abi.Indirect:
|
||||
|
||||
@@ -417,8 +417,9 @@ func (p Program) toLLVMStruct(raw *types.Struct) (ret llvm.Type, kind valueKind)
|
||||
func isClosure(raw *types.Struct) bool {
|
||||
n := raw.NumFields()
|
||||
if n == 2 {
|
||||
if _, ok := raw.Field(0).Type().(*types.Signature); ok {
|
||||
return raw.Field(1).Type() == types.Typ[types.UnsafePointer]
|
||||
f1, f2 := raw.Field(0), raw.Field(1)
|
||||
if _, ok := f1.Type().(*types.Signature); ok && f1.Name() == "$f" {
|
||||
return f2.Type() == types.Typ[types.UnsafePointer] && f2.Name() == "$data"
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -176,8 +176,8 @@ func Instantiate(orig types.Type, t *types.Named) (types.Type, bool) {
|
||||
func (p goTypes) cvtClosure(sig *types.Signature) *types.Struct {
|
||||
raw := p.cvtFunc(sig, nil)
|
||||
flds := []*types.Var{
|
||||
types.NewField(token.NoPos, nil, "f", raw, false),
|
||||
types.NewField(token.NoPos, nil, "data", types.Typ[types.UnsafePointer], false),
|
||||
types.NewField(token.NoPos, nil, "$f", raw, false),
|
||||
types.NewField(token.NoPos, nil, "$data", types.Typ[types.UnsafePointer], false),
|
||||
}
|
||||
return types.NewStruct(flds, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user