mirror of
https://github.com/kubenetworks/kubevpn.git
synced 2025-10-13 02:53:52 +08:00
chore: upgrade coredns version (#550)
This commit is contained in:
43
vendor/github.com/expr-lang/expr/optimizer/in_range.go
generated
vendored
Normal file
43
vendor/github.com/expr-lang/expr/optimizer/in_range.go
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
package optimizer
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
. "github.com/expr-lang/expr/ast"
|
||||
)
|
||||
|
||||
type inRange struct{}
|
||||
|
||||
func (*inRange) Visit(node *Node) {
|
||||
switch n := (*node).(type) {
|
||||
case *BinaryNode:
|
||||
if n.Operator == "in" {
|
||||
t := n.Left.Type()
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
if t.Kind() != reflect.Int {
|
||||
return
|
||||
}
|
||||
if rangeOp, ok := n.Right.(*BinaryNode); ok && rangeOp.Operator == ".." {
|
||||
if from, ok := rangeOp.Left.(*IntegerNode); ok {
|
||||
if to, ok := rangeOp.Right.(*IntegerNode); ok {
|
||||
patchCopyType(node, &BinaryNode{
|
||||
Operator: "and",
|
||||
Left: &BinaryNode{
|
||||
Operator: ">=",
|
||||
Left: n.Left,
|
||||
Right: from,
|
||||
},
|
||||
Right: &BinaryNode{
|
||||
Operator: "<=",
|
||||
Left: n.Left,
|
||||
Right: to,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user