MCPcopy Create free account
hub / github.com/cel-expr/cel-go / qualifyInternal

Method qualifyInternal

interpreter/attributes.go:951–1044  ·  view source on GitHub ↗
(vars Activation, obj any, presenceTest, presenceOnly bool)

Source from the content-addressed store, hash-verified

949}
950
951func (q *intQualifier) qualifyInternal(vars Activation, obj any, presenceTest, presenceOnly bool) (any, bool, error) {
952 i := q.value
953 var isMap bool
954 switch o := obj.(type) {
955 // The specialized map types supported by an int qualifier are considerably fewer than the set
956 // of specialized map types supported by string qualifiers since they are less frequently used
957 // than string-based map keys. Additional specializations may be added in the future if
958 // desired.
959 case map[int]any:
960 isMap = true
961 obj, isKey := o[int(i)]
962 if isKey {
963 return obj, true, nil
964 }
965 case map[int32]any:
966 isMap = true
967 if i32 := int32(i); int64(i32) == i {
968 obj, isKey := o[i32]
969 if isKey {
970 return obj, true, nil
971 }
972 }
973 case map[int64]any:
974 isMap = true
975 obj, isKey := o[i]
976 if isKey {
977 return obj, true, nil
978 }
979 case []any:
980 isIndex := i >= 0 && i < int64(len(o))
981 if isIndex {
982 return o[i], true, nil
983 }
984 case []string:
985 isIndex := i >= 0 && i < int64(len(o))
986 if isIndex {
987 return o[i], true, nil
988 }
989 case []int:
990 isIndex := i >= 0 && i < int64(len(o))
991 if isIndex {
992 return o[i], true, nil
993 }
994 case []int32:
995 isIndex := i >= 0 && i < int64(len(o))
996 if isIndex {
997 return o[i], true, nil
998 }
999 case []int64:
1000 isIndex := i >= 0 && i < int64(len(o))
1001 if isIndex {
1002 return o[i], true, nil
1003 }
1004 case []uint:
1005 isIndex := i >= 0 && i < int64(len(o))
1006 if isIndex {
1007 return o[i], true, nil
1008 }

Callers 2

QualifyMethod · 0.95
QualifyIfPresentMethod · 0.95

Calls 3

refQualifyFunction · 0.85
missingKeyFunction · 0.85
missingIndexFunction · 0.85

Tested by

no test coverage detected