MCPcopy
hub / github.com/expr-lang/expr / MethodIndex

Function MethodIndex

checker/info.go:30–49  ·  view source on GitHub ↗
(c *Cache, env Nature, node ast.Node)

Source from the content-addressed store, hash-verified

28}
29
30func MethodIndex(c *Cache, env Nature, node ast.Node) (bool, int, string) {
31 switch n := node.(type) {
32 case *ast.IdentifierNode:
33 if env.Kind == reflect.Struct {
34 if m, ok := env.Get(c, n.Value); ok && m.TypeData != nil {
35 return m.Method, m.MethodIndex, n.Value
36 }
37 }
38 case *ast.MemberNode:
39 if name, ok := n.Property.(*ast.StringNode); ok {
40 base := n.Node.Type()
41 if base != nil && base.Kind() != reflect.Interface {
42 if m, ok := base.MethodByName(name.Value); ok {
43 return true, m.Index, name.Value
44 }
45 }
46 }
47 }
48 return false, 0, ""
49}
50
51func TypedFuncIndex(fn reflect.Type, method bool) (int, bool) {
52 if fn == nil {

Callers 3

IdentifierNodeMethod · 0.92
MemberNodeMethod · 0.92
CallNodeMethod · 0.92

Calls 3

MethodByNameMethod · 0.80
GetMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…