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

Method Visit

patcher/operator_override.go:22–45  ·  view source on GitHub ↗
(node *ast.Node)

Source from the content-addressed store, hash-verified

20}
21
22func (p *OperatorOverloading) Visit(node *ast.Node) {
23 binaryNode, ok := (*node).(*ast.BinaryNode)
24 if !ok {
25 return
26 }
27
28 if binaryNode.Operator != p.Operator {
29 return
30 }
31
32 leftType := binaryNode.Left.Type()
33 rightType := binaryNode.Right.Type()
34
35 ret, fn, ok := p.FindSuitableOperatorOverload(leftType, rightType)
36 if ok {
37 newNode := &ast.CallNode{
38 Callee: &ast.IdentifierNode{Value: fn},
39 Arguments: []ast.Node{binaryNode.Left, binaryNode.Right},
40 }
41 newNode.SetType(ret)
42 ast.Patch(node, newNode)
43 p.applied = true
44 }
45}
46
47// Tracking must be reset before every walk over the AST tree
48func (p *OperatorOverloading) Reset() {

Callers

nothing calls this directly

Calls 4

PatchFunction · 0.92
TypeMethod · 0.65
SetTypeMethod · 0.65

Tested by

no test coverage detected