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

Method addMethod

types/methods.go:71–93  ·  view source on GitHub ↗

EXCLUSIVE_LOCKS_REQUIRED(prog.methodsMu)

(mset *ssaMethodSet, sel *Selection)

Source from the content-addressed store, hash-verified

69
70// EXCLUSIVE_LOCKS_REQUIRED(prog.methodsMu)
71func (prog *Program) addMethod(mset *ssaMethodSet, sel *Selection) *Function {
72 if sel.Kind() == MethodExpr {
73 panic(sel)
74 }
75 id := sel.Obj().Id()
76 fn := mset.mapping[id]
77 if fn == nil {
78 obj := sel.Obj().(*Func)
79
80 needsPromotion := len(sel.Index()) > 1
81 needsIndirection := !isPointer(recvType(obj)) && isPointer(sel.Recv())
82 if needsPromotion || needsIndirection {
83 fn = prog.makeWrapper(sel)
84 } else {
85 fn = prog.declaredFunc(obj)
86 }
87 if fn.Signature.Recv() == nil {
88 panic(fn) // missing receiver
89 }
90 mset.mapping[id] = fn
91 }
92 return fn
93}
94
95// RuntimeTypes returns a new unordered slice containing all
96// concrete types in the program for which a complete (non-empty)

Callers 2

MethodValueMethod · 0.95
needMethodsMethod · 0.95

Calls 9

makeWrapperMethod · 0.95
declaredFuncMethod · 0.95
isPointerFunction · 0.85
recvTypeFunction · 0.85
IdMethod · 0.65
KindMethod · 0.45
ObjMethod · 0.45
IndexMethod · 0.45
RecvMethod · 0.45

Tested by

no test coverage detected