MCPcopy Create free account
hub / github.com/despiteallobjections/amigo / MethodValue

Method MethodValue

types/methods.go:23–39  ·  view source on GitHub ↗

MethodValue returns the Function implementing method sel, building wrapper methods on demand. It returns nil if sel denotes an abstract (interface) method. Precondition: sel.Kind() == MethodVal. Thread-safe. EXCLUSIVE_LOCKS_ACQUIRED(prog.methodsMu)

(sel *Selection)

Source from the content-addressed store, hash-verified

21// EXCLUSIVE_LOCKS_ACQUIRED(prog.methodsMu)
22//
23func (prog *Program) MethodValue(sel *Selection) *Function {
24 if sel.Kind() != MethodVal {
25 panic(fmt.Sprintf("MethodValue(%s) kind != MethodVal", sel))
26 }
27 T := sel.Recv()
28 if isInterface(T) {
29 return nil // abstract method
30 }
31 if prog.mode&LogSource != 0 {
32 defer logStack("MethodValue %s %v", T, sel)()
33 }
34
35 prog.methodsMu.Lock()
36 defer prog.methodsMu.Unlock()
37
38 return prog.addMethod(prog.createMethodSet(T), sel)
39}
40
41// LookupMethod returns the implementation of the method of type T
42// identified by (pkg, name). It returns nil if the method exists but

Callers 3

LookupMethodMethod · 0.95
programMethod · 0.80
initReflectFunction · 0.80

Calls 6

addMethodMethod · 0.95
createMethodSetMethod · 0.95
isInterfaceFunction · 0.85
logStackFunction · 0.85
KindMethod · 0.45
RecvMethod · 0.45

Tested by

no test coverage detected