@@ -9,15 +9,15 @@ import (
99 "github.com/expr-lang/expr/conf"
1010)
1111
12- type OperatorOverride struct {
13- Operator string // Operator token to override .
14- Overrides []string // List of function names to override operator with.
12+ type OperatorOverloading struct {
13+ Operator string // Operator token to overload .
14+ Overloads []string // List of function names to replace operator with.
1515 Types conf.TypesTable // Env types.
1616 Functions conf.FunctionsTable // Env functions.
17- applied bool // Flag to indicate if any override was applied .
17+ applied bool // Flag to indicate if any changes were made to the tree .
1818}
1919
20- func (p * OperatorOverride ) Visit (node * ast.Node ) {
20+ func (p * OperatorOverloading ) Visit (node * ast.Node ) {
2121 binaryNode , ok := (* node ).(* ast.BinaryNode )
2222 if ! ok {
2323 return
@@ -42,20 +42,20 @@ func (p *OperatorOverride) Visit(node *ast.Node) {
4242 }
4343}
4444
45- func (p * OperatorOverride ) ShouldRepeat () bool {
45+ func (p * OperatorOverloading ) ShouldRepeat () bool {
4646 return p .applied
4747}
4848
49- func (p * OperatorOverride ) FindSuitableOperatorOverload (l , r reflect.Type ) (reflect.Type , string , bool ) {
49+ func (p * OperatorOverloading ) FindSuitableOperatorOverload (l , r reflect.Type ) (reflect.Type , string , bool ) {
5050 t , fn , ok := p .findSuitableOperatorOverloadInFunctions (l , r )
5151 if ! ok {
5252 t , fn , ok = p .findSuitableOperatorOverloadInTypes (l , r )
5353 }
5454 return t , fn , ok
5555}
5656
57- func (p * OperatorOverride ) findSuitableOperatorOverloadInTypes (l , r reflect.Type ) (reflect.Type , string , bool ) {
58- for _ , fn := range p .Overrides {
57+ func (p * OperatorOverloading ) findSuitableOperatorOverloadInTypes (l , r reflect.Type ) (reflect.Type , string , bool ) {
58+ for _ , fn := range p .Overloads {
5959 fnType , ok := p .Types [fn ]
6060 if ! ok {
6161 continue
@@ -72,8 +72,8 @@ func (p *OperatorOverride) findSuitableOperatorOverloadInTypes(l, r reflect.Type
7272 return nil , "" , false
7373}
7474
75- func (p * OperatorOverride ) findSuitableOperatorOverloadInFunctions (l , r reflect.Type ) (reflect.Type , string , bool ) {
76- for _ , fn := range p .Overrides {
75+ func (p * OperatorOverloading ) findSuitableOperatorOverloadInFunctions (l , r reflect.Type ) (reflect.Type , string , bool ) {
76+ for _ , fn := range p .Overloads {
7777 fnType , ok := p .Functions [fn ]
7878 if ! ok {
7979 continue
@@ -101,8 +101,8 @@ func checkTypeSuits(t reflect.Type, l reflect.Type, r reflect.Type, firstInIndex
101101 return nil , false
102102}
103103
104- func (p * OperatorOverride ) Check () {
105- for _ , fn := range p .Overrides {
104+ func (p * OperatorOverloading ) Check () {
105+ for _ , fn := range p .Overloads {
106106 fnType , foundType := p .Types [fn ]
107107 fnFunc , foundFunc := p .Functions [fn ]
108108 if ! foundFunc && (! foundType || fnType .Type .Kind () != reflect .Func ) {
0 commit comments