@@ -2,14 +2,8 @@ package conf
22
33import (
44 "reflect"
5-
6- "github.com/expr-lang/expr/ast"
75)
86
9- // OperatorsTable maps binary operators to corresponding list of functions.
10- // Functions should be provided in the environment to allow operator overloading.
11- type OperatorsTable map [string ][]string
12-
137func FindSuitableOperatorOverload (fns []string , types TypesTable , funcs FunctionTable , l , r reflect.Type ) (reflect.Type , string , bool ) {
148 t , fn , ok := FindSuitableOperatorOverloadInFunctions (fns , funcs , l , r )
159 if ! ok {
@@ -64,34 +58,3 @@ func checkTypeSuits(t reflect.Type, l reflect.Type, r reflect.Type, firstInIndex
6458 }
6559 return nil , false
6660}
67-
68- type OperatorPatcher struct {
69- Operators OperatorsTable
70- Types TypesTable
71- Functions FunctionTable
72- }
73-
74- func (p * OperatorPatcher ) Visit (node * ast.Node ) {
75- binaryNode , ok := (* node ).(* ast.BinaryNode )
76- if ! ok {
77- return
78- }
79-
80- fns , ok := p .Operators [binaryNode .Operator ]
81- if ! ok {
82- return
83- }
84-
85- leftType := binaryNode .Left .Type ()
86- rightType := binaryNode .Right .Type ()
87-
88- ret , fn , ok := FindSuitableOperatorOverload (fns , p .Types , p .Functions , leftType , rightType )
89- if ok {
90- newNode := & ast.CallNode {
91- Callee : & ast.IdentifierNode {Value : fn },
92- Arguments : []ast.Node {binaryNode .Left , binaryNode .Right },
93- }
94- newNode .SetType (ret )
95- ast .Patch (node , newNode )
96- }
97- }
0 commit comments