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

Function traverseAndReplaceIntegerNodesWithFloatNodes

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

Source from the content-addressed store, hash-verified

1173}
1174
1175func traverseAndReplaceIntegerNodesWithFloatNodes(node *ast.Node, newNature Nature) {
1176 switch (*node).(type) {
1177 case *ast.IntegerNode:
1178 *node = &ast.FloatNode{Value: float64((*node).(*ast.IntegerNode).Value)}
1179 (*node).SetType(newNature.Type)
1180 case *ast.UnaryNode:
1181 unaryNode := (*node).(*ast.UnaryNode)
1182 traverseAndReplaceIntegerNodesWithFloatNodes(&unaryNode.Node, newNature)
1183 case *ast.BinaryNode:
1184 binaryNode := (*node).(*ast.BinaryNode)
1185 switch binaryNode.Operator {
1186 case "+", "-", "*":
1187 traverseAndReplaceIntegerNodesWithFloatNodes(&binaryNode.Left, newNature)
1188 traverseAndReplaceIntegerNodesWithFloatNodes(&binaryNode.Right, newNature)
1189 }
1190 }
1191}
1192
1193func traverseAndReplaceIntegerNodesWithIntegerNodes(node *ast.Node, newNature Nature) {
1194 switch (*node).(type) {

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…