Skip to content

Commit 3196510

Browse files
committed
Fix naming
1 parent 323873a commit 3196510

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

Diff for: expr.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ func AllowUndefinedVariables() Option {
4242
// Operator allows to replace a binary operator with a function.
4343
func Operator(operator string, fn ...string) Option {
4444
return func(c *conf.Config) {
45-
p := &patcher.OperatorOverride{
45+
p := &patcher.OperatorOverloading{
4646
Operator: operator,
47-
Overrides: fn,
47+
Overloads: fn,
4848
Types: c.Types,
4949
Functions: c.Functions,
5050
}

Diff for: patcher/operator_override.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)