MCPcopy Index your code
hub / github.com/expr-lang/expr / Visit

Method Visit

optimizer/predicate_combination.go:18–44  ·  view source on GitHub ↗
(node *Node)

Source from the content-addressed store, hash-verified

16type predicateCombination struct{}
17
18func (v *predicateCombination) Visit(node *Node) {
19 if op, ok := (*node).(*BinaryNode); ok && operator.IsBoolean(op.Operator) {
20 if left, ok := op.Left.(*BuiltinNode); ok {
21 if combinedOp, ok := combinedOperator(left.Name, op.Operator); ok {
22 if right, ok := op.Right.(*BuiltinNode); ok && right.Name == left.Name {
23 if left.Arguments[0].Type() == right.Arguments[0].Type() && left.Arguments[0].String() == right.Arguments[0].String() {
24 predicate := &PredicateNode{
25 Node: &BinaryNode{
26 Operator: combinedOp,
27 Left: left.Arguments[1].(*PredicateNode).Node,
28 Right: right.Arguments[1].(*PredicateNode).Node,
29 },
30 }
31 v.Visit(&predicate.Node)
32 patchCopyType(node, &BuiltinNode{
33 Name: left.Name,
34 Arguments: []Node{
35 left.Arguments[0],
36 predicate,
37 },
38 })
39 }
40 }
41 }
42 }
43 }
44}
45
46func combinedOperator(fn, op string) (string, bool) {
47 switch {

Callers

nothing calls this directly

Calls 5

IsBooleanFunction · 0.92
combinedOperatorFunction · 0.85
patchCopyTypeFunction · 0.85
TypeMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected