@@ -2,14 +2,8 @@ package conf
2
2
3
3
import (
4
4
"reflect"
5
-
6
- "github.com/expr-lang/expr/ast"
7
5
)
8
6
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
-
13
7
func FindSuitableOperatorOverload (fns []string , types TypesTable , funcs FunctionTable , l , r reflect.Type ) (reflect.Type , string , bool ) {
14
8
t , fn , ok := FindSuitableOperatorOverloadInFunctions (fns , funcs , l , r )
15
9
if ! ok {
@@ -64,34 +58,3 @@ func checkTypeSuits(t reflect.Type, l reflect.Type, r reflect.Type, firstInIndex
64
58
}
65
59
return nil , false
66
60
}
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