Bump cel-go to v0.11.2
This commit is contained in:
36
vendor/github.com/google/cel-go/checker/decls/scopes.go
generated
vendored
36
vendor/github.com/google/cel-go/checker/decls/scopes.go
generated
vendored
@@ -33,6 +33,19 @@ func NewScopes() *Scopes {
|
||||
}
|
||||
}
|
||||
|
||||
// Copy creates a copy of the current Scopes values, including a copy of its parent if non-nil.
|
||||
func (s *Scopes) Copy() *Scopes {
|
||||
cpy := NewScopes()
|
||||
if s == nil {
|
||||
return cpy
|
||||
}
|
||||
if s.parent != nil {
|
||||
cpy.parent = s.parent.Copy()
|
||||
}
|
||||
cpy.scopes = s.scopes.copy()
|
||||
return cpy
|
||||
}
|
||||
|
||||
// Push creates a new Scopes value which references the current Scope as its parent.
|
||||
func (s *Scopes) Push() *Scopes {
|
||||
return &Scopes{
|
||||
@@ -80,9 +93,9 @@ func (s *Scopes) FindIdentInScope(name string) *exprpb.Decl {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddFunction adds the function Decl to the current scope.
|
||||
// SetFunction adds the function Decl to the current scope.
|
||||
// Note: Any previous entry for a function in the current scope with the same name is overwritten.
|
||||
func (s *Scopes) AddFunction(fn *exprpb.Decl) {
|
||||
func (s *Scopes) SetFunction(fn *exprpb.Decl) {
|
||||
s.scopes.functions[fn.Name] = fn
|
||||
}
|
||||
|
||||
@@ -100,13 +113,30 @@ func (s *Scopes) FindFunction(name string) *exprpb.Decl {
|
||||
}
|
||||
|
||||
// Group is a set of Decls that is pushed on or popped off a Scopes as a unit.
|
||||
// Contains separate namespaces for idenifier and function Decls.
|
||||
// Contains separate namespaces for identifier and function Decls.
|
||||
// (Should be named "Scope" perhaps?)
|
||||
type Group struct {
|
||||
idents map[string]*exprpb.Decl
|
||||
functions map[string]*exprpb.Decl
|
||||
}
|
||||
|
||||
// copy creates a new Group instance with a shallow copy of the variables and functions.
|
||||
// If callers need to mutate the exprpb.Decl definitions for a Function, they should copy-on-write.
|
||||
func (g *Group) copy() *Group {
|
||||
cpy := &Group{
|
||||
idents: make(map[string]*exprpb.Decl, len(g.idents)),
|
||||
functions: make(map[string]*exprpb.Decl, len(g.functions)),
|
||||
}
|
||||
for n, id := range g.idents {
|
||||
cpy.idents[n] = id
|
||||
}
|
||||
for n, fn := range g.functions {
|
||||
cpy.functions[n] = fn
|
||||
}
|
||||
return cpy
|
||||
}
|
||||
|
||||
// newGroup creates a new Group with empty maps for identifiers and functions.
|
||||
func newGroup() *Group {
|
||||
return &Group{
|
||||
idents: make(map[string]*exprpb.Decl),
|
||||
|
||||
Reference in New Issue
Block a user