MCPcopy
hub / github.com/tinylib/msgp / imutMethodReceiver

Function imutMethodReceiver

gen/spec.go:313–340  ·  view source on GitHub ↗

possibly-immutable method receiver

(p Elem)

Source from the content-addressed store, hash-verified

311
312// possibly-immutable method receiver
313func imutMethodReceiver(p Elem) string {
314 typeName := p.BaseTypeName()
315 typeParams := p.TypeParams()
316
317 switch e := p.(type) {
318 case *Struct:
319 // TODO(HACK): actually do real math here.
320 if len(e.Fields) <= 3 {
321 for i := range e.Fields {
322 if be, ok := e.Fields[i].FieldElem.(*BaseElem); !ok || (be.Value == IDENT || be.Value == Bytes) {
323 goto nope
324 }
325 }
326 return typeName + typeParams.TypeParams
327 }
328 nope:
329 return "*" + typeName + typeParams.TypeParams
330
331 // gets dereferenced automatically
332 case *Array:
333 return "*" + typeName + typeParams.TypeParams
334
335 // everything else can be
336 // by-value.
337 default:
338 return typeName + typeParams.TypeParams
339 }
340}
341
342// if necessary, wraps a type
343// so that its method receiver

Callers 3

ExecuteMethod · 0.85
ExecuteMethod · 0.85
ExecuteMethod · 0.85

Calls 2

BaseTypeNameMethod · 0.65
TypeParamsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…