本文整理汇总了Golang中go/types.Signature.Recv方法的典型用法代码示例。如果您正苦于以下问题:Golang Signature.Recv方法的具体用法?Golang Signature.Recv怎么用?Golang Signature.Recv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类go/types.Signature
的用法示例。
在下文中一共展示了Signature.Recv方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: signature
func (p *exporter) signature(sig *types.Signature) {
// We need the receiver information (T vs *T)
// for methods associated with named types.
// We do not record interface receiver types in the
// export data because 1) the importer can derive them
// from the interface type and 2) they create cycles
// in the type graph.
if recv := sig.Recv(); recv != nil {
if _, ok := recv.Type().Underlying().(*types.Interface); !ok {
// 1-element tuple
p.int(1)
p.param(recv)
} else {
// 0-element tuple
p.int(0)
}
} else {
// 0-element tuple
p.int(0)
}
p.tuple(sig.Params())
p.tuple(sig.Results())
if sig.Variadic() {
p.int(1)
} else {
p.int(0)
}
}
示例2: newSignatureFrom
func newSignatureFrom(pkg *Package, sig *types.Signature) *Signature {
var recv *Var
if sig.Recv() != nil {
recv = newVarFrom(pkg, sig.Recv())
}
return &Signature{
ret: newVarsFrom(pkg, sig.Results()),
args: newVarsFrom(pkg, sig.Params()),
recv: recv,
}
}
示例3: convertSignature
func (b *Builder) convertSignature(u types.Universe, t *tc.Signature) *types.Signature {
signature := &types.Signature{}
for i := 0; i < t.Params().Len(); i++ {
signature.Parameters = append(signature.Parameters, b.walkType(u, nil, t.Params().At(i).Type()))
}
for i := 0; i < t.Results().Len(); i++ {
signature.Results = append(signature.Results, b.walkType(u, nil, t.Results().At(i).Type()))
}
if r := t.Recv(); r != nil {
signature.Receiver = b.walkType(u, nil, r.Type())
}
signature.Variadic = t.Variadic()
return signature
}
示例4: writeSignature
// writeSignature writes to buf the signature sig in declaration syntax.
func writeSignature(buf *bytes.Buffer, from *types.Package, name string, sig *types.Signature, params []*Parameter) {
buf.WriteString("func ")
if recv := sig.Recv(); recv != nil {
buf.WriteString("(")
if n := params[0].Name(); n != "" {
buf.WriteString(n)
buf.WriteString(" ")
}
types.WriteType(buf, params[0].Type(), types.RelativeTo(from))
buf.WriteString(") ")
}
buf.WriteString(name)
types.WriteSignature(buf, sig, types.RelativeTo(from))
}
示例5: convertSignature
func (c *converter) convertSignature(v *gotypes.Signature) *types.Signature {
if v == nil {
return nil
}
if v, ok := c.converted[v]; ok {
return v.(*types.Signature)
}
ret := types.NewSignature(
c.convertParamVar(v.Recv()),
c.convertTuple(v.Params(), c.convertParamVar),
c.convertTuple(v.Results(), c.convertParamVar),
v.Variadic(),
)
c.converted[v] = ret
return ret
}