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

Function traverseAndReplaceIntegerNodesWithIntegerNodes

checker/checker.go:1193–1210  ·  view source on GitHub ↗
(node *ast.Node, newNature Nature)

Source from the content-addressed store, hash-verified

1191}
1192
1193func traverseAndReplaceIntegerNodesWithIntegerNodes(node *ast.Node, newNature Nature) {
1194 switch (*node).(type) {
1195 case *ast.IntegerNode:
1196 (*node).SetType(newNature.Type)
1197 case *ast.UnaryNode:
1198 (*node).SetType(newNature.Type)
1199 unaryNode := (*node).(*ast.UnaryNode)
1200 traverseAndReplaceIntegerNodesWithIntegerNodes(&unaryNode.Node, newNature)
1201 case *ast.BinaryNode:
1202 // TODO: Binary node return type is dependent on the type of the operands. We can't just change the type of the node.
1203 binaryNode := (*node).(*ast.BinaryNode)
1204 switch binaryNode.Operator {
1205 case "+", "-", "*":
1206 traverseAndReplaceIntegerNodesWithIntegerNodes(&binaryNode.Left, newNature)
1207 traverseAndReplaceIntegerNodesWithIntegerNodes(&binaryNode.Right, newNature)
1208 }
1209 }
1210}
1211
1212func (v *Checker) predicateNode(node *ast.PredicateNode) Nature {
1213 nt := v.visit(node.Node)

Callers 1

checkArgumentsMethod · 0.85

Calls 1

SetTypeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…