mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
rebase: bump k8s.io/kubernetes from 1.26.2 to 1.27.2
Bumps [k8s.io/kubernetes](https://github.com/kubernetes/kubernetes) from 1.26.2 to 1.27.2. - [Release notes](https://github.com/kubernetes/kubernetes/releases) - [Commits](https://github.com/kubernetes/kubernetes/compare/v1.26.2...v1.27.2) --- updated-dependencies: - dependency-name: k8s.io/kubernetes dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
mergify[bot]
parent
0e79135419
commit
07b05616a0
go.modgo.summodules.txt
vendor
github.com
NYTimes
gziphandler
antlr
antlr4
runtime
Go
antlr
LICENSEatn.goatn_config.goatn_config_set.goatn_deserialization_options.goatn_deserializer.goatn_simulator.goatn_state.goatn_type.gochar_stream.gocommon_token_factory.gocommon_token_stream.godfa.godfa_serializer.godfa_state.godiagnostic_error_listener.goerror_listener.goerror_strategy.goerrors.gofile_stream.goinput_stream.goint_stream.gointerval_set.golexer.golexer_action.golexer_action_executor.golexer_atn_simulator.goll1_analyzer.goparser.goparser_atn_simulator.goparser_rule_context.goprediction_context.goprediction_mode.gorecognizer.gorule_context.gosemantic_context.gotoken.gotoken_source.gotoken_stream.gotokenstream_rewriter.gotrace_listener.gotransition.gotree.gotrees.goutils.goutils_set.go
aws
aws-sdk-go
private
protocol
ec2query
service
coreos
go-semver
go-systemd
go-openapi
gogo
protobuf
gogoproto
protoc-gen-gogo
google
cel-go
LICENSE
cel
checker
common
BUILD.bazel
containers
cost.godebug
doc.goerror.goerrors.golocation.gooperators
overloads
runes
source.gotypes
BUILD.bazelany_value.gobool.gobytes.gocompare.godoc.godouble.goduration.goerr.goint.goiterator.gojson_value.golist.gomap.gonull.goobject.gooverflow.go
pb
provider.goref
string.gotimestamp.gotraits
BUILD.bazelcomparer.gocontainer.gofield_tester.goindexer.goiterator.golister.gomapper.gomatcher.gomath.goreceiver.gosizer.gotraits.go
type.gouint.gounknown.goutil.goext
interpreter
BUILD.bazelactivation.goattribute_patterns.goattributes.gocoster.godecorators.godispatcher.goevalstate.go
functions
interpretable.gointerpreter.gooptimizations.goplanner.goprune.goruntimecost.goparser
onsi
gomega
gcustom
stoewer
go.etcd.io
etcd
api
v3
client
pkg
v3
LICENSE
fileutil
dir_unix.godir_windows.godoc.gofilereader.gofileutil.golock.golock_flock.golock_linux.golock_plan9.golock_solaris.golock_unix.golock_windows.gopreallocate.gopreallocate_darwin.gopreallocate_unix.gopreallocate_unsupported.gopurge.goread_dir.gosync.gosync_darwin.gosync_linux.go
logutil
systemd
tlsutil
transport
doc.gokeepalive_listener.golimit_listen.golistener.golistener_opts.golistener_tls.gosockopt.gosockopt_solaris.gosockopt_unix.gosockopt_windows.gotimeout_conn.gotimeout_dialer.gotimeout_listener.gotimeout_transport.gotls.gotransport.gounix_listener.go
types
v3
go.opentelemetry.io
contrib
instrumentation
google.golang.org
grpc
net
http
otelhttp
go.uber.org
zap
zapgrpc
golang.org
x
crypto
cryptobyte
nacl
secretbox
salsa20
net
sync
text
google.golang.org
genproto
googleapis
grpc
resolver
manual
protobuf
types
gopkg.in
natefinch
k8s.io
apimachinery
pkg
apis
meta
util
waitgroup
apiserver
pkg
admission
cel
plugin
namespace
lifecycle
validatingadmissionpolicy
OWNERSadmission.gocompiler.gocontroller.gocontroller_reconcile.goinitializer.gointerface.go
internal
matching
policy_decision.govalidator.gowebhook
validating
apis
audit
config
doc.goregister.gotypes.go
v1
defaults.godoc.goregister.gotypes.gozz_generated.conversion.gozz_generated.deepcopy.gozz_generated.defaults.go
validation
zz_generated.deepcopy.goflowcontrol
bootstrap
audit
authentication
authenticator
authenticatorfactory
group
request
anonymous
bearertoken
headerrequest
union
websocket
x509
serviceaccount
token
authorization
cel
endpoints
deprecation
discovery
doc.gofilterlatency
filters
OWNERSaudit.goaudit_init.goauthentication.goauthn_audit.goauthorization.gocachecontrol.godoc.goimpersonation.gometrics.gomux_discovery_complete.gorequest_deadline.gorequest_received_time.gorequestinfo.gostorageversion.gotraces.gowarning.gowebhook_duration.go
groupversion.gohandlers
create.godelete.godoc.go
installer.gofieldmanager
OWNERSadmission.gobuildmanagerinfo.gocapmanagers.goendpoints.yamlequality.gofieldmanager.go
internal
lastappliedmanager.golastappliedupdater.gomanagedfieldsupdater.gonode.yamlpod.yamlscalehandler.goskipnonapplied.gostripmeta.gostructuredmerge.gotypeconverter.goversionconverter.gofinisher
get.gohelpers.gometrics
namer.gonegotiation
patch.goresponse.goresponsewriters
rest.gotrace_util.goupdate.gowatch.gometrics
openapi
responsewriter
warning
registry
server
config.goconfig_selfclient.godeleted_kinds.godeprecated_insecure_serving.godoc.go
dynamiccertificates
cert_key.goclient_ca.goconfigmap_cafile_content.godynamic_cafile_content.godynamic_serving_content.godynamic_sni_content.gointerfaces.gonamed_certificates.gostatic_content.gotlsconfig.gounion_content.goutil.go
filters
OWNERScontent_type.gocors.godoc.gogoaway.gohsts.golongrunning.gomaxinflight.gopriority-and-fairness.gotimeout.gowaitgroup.gowith_retry_after.gowrap.go
genericapiserver.gohandler.gohealthz.gohealthz
hooks.gohttplog
lifecycle_signals.gomux
options
OWNERSadmission.goapi_enablement.goaudit.goauthentication.goauthentication_dynamic_request_header.goauthorization.gocoreapi.godeprecated_insecure_serving.godoc.goegress_selector.go
plugins.goencryptionconfig
etcd.gofeature.gorecommended.goserver_run_options.goserving.goserving_unix.goserving_windows.goserving_with_loopback.gotracing.goresourceconfig
routes
secure_serving.gosignal.gosignal_posix.gosignal_windows.gostorage
storage
OWNERSapi_object_versioner.go
cacher
continue.godoc.goerrors.goerrors
etcd3
OWNERScompact.goerrors.goevent.gohealthcheck.golatency_tracker.golease_manager.gologger.go
interfaces.goselection_predicate.gometrics
store.gowatcher.gostoragebackend
util.govalue
OWNERS
encrypt
metrics.gotransformer.gostorageversion
util
apihelpers
dryrun
flowcontrol
OWNERSapf_context.goapf_controller.goapf_controller_debug.goapf_filter.goconc_alloc.go
debug
fairqueuing
format
formatting.gometrics
request
config.golist_work_estimator.gomutating_work_estimator.goobject_count_tracker.goseat_seconds.gowidth.go
rule.gowatch_tracker.goflushwriter
openapi
shufflesharding
wsstream
plugin
pkg
audit
authenticator
token
webhook
authorizer
client-go
dynamic
cloud-provider
app
config
config
doc.go
install
register.gotypes.gov1alpha1
conversion.godefaults.godoc.goregister.gotypes.gozz_generated.conversion.gozz_generated.deepcopy.gozz_generated.defaults.go
zz_generated.deepcopy.gocontrollers
service
options
component-base
config
options
logs
metrics
controller-manager
LICENSE
config
options
pkg
clientbuilder
features
leadermigration
kms
kube-openapi
pkg
builder
builder3
cached
common
common.go
restfuladapter
handler
handler3
internal
schemaconv
spec3
encoding.goexample.goexternal_documentation.gofuzz.goheader.gomedia_type.gooperation.goparameter.gopath.gorequest_body.goresponse.gosecurity_requirement.gosecurity_scheme.goserver.gospec.go
util
validation
kubelet
pkg
kubernetes
pkg
api
apis
apps
autoscaling
batch
core
extensions
networking
policy
client
conditions
cluster
ports
controller
features
fieldpath
kubelet
proxy
securitycontext
volume
test
e2e
framework
.import-restrictionsOWNERSREADME.md
config
debug
expect.goframework.goget.goginkgowrapper.gointernal
junit
kubectl
log.gometrics
namespacedname.gonode
pod
.import-restrictionscreate.godelete.godial.goexec_util.goget.go
provider.gooutput
pod_client.goresource.goutils.gowait.gopv
skipper
ssh
test_context.gotestfiles
timeouts.goutil.govolume
storage
testing-manifests
utils
utils
lru
sigs.k8s.io
apiserver-network-proxy
konnectivity-client
json
structured-merge-diff
v4
merge
20
vendor/github.com/google/cel-go/checker/decls/BUILD.bazel
generated
vendored
Normal file
20
vendor/github.com/google/cel-go/checker/decls/BUILD.bazel
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
licenses = ["notice"], # Apache 2.0
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"decls.go",
|
||||
"scopes.go",
|
||||
],
|
||||
importpath = "github.com/google/cel-go/checker/decls",
|
||||
deps = [
|
||||
"@org_golang_google_genproto//googleapis/api/expr/v1alpha1:go_default_library",
|
||||
"@org_golang_google_protobuf//types/known/emptypb:go_default_library",
|
||||
"@org_golang_google_protobuf//types/known/structpb:go_default_library",
|
||||
],
|
||||
)
|
231
vendor/github.com/google/cel-go/checker/decls/decls.go
generated
vendored
Normal file
231
vendor/github.com/google/cel-go/checker/decls/decls.go
generated
vendored
Normal file
@ -0,0 +1,231 @@
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package decls provides helpers for creating variable and function declarations.
|
||||
package decls
|
||||
|
||||
import (
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
structpb "google.golang.org/protobuf/types/known/structpb"
|
||||
exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
|
||||
)
|
||||
|
||||
var (
|
||||
// Error type used to communicate issues during type-checking.
|
||||
Error = &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_Error{
|
||||
Error: &emptypb.Empty{}}}
|
||||
|
||||
// Dyn is a top-type used to represent any value.
|
||||
Dyn = &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_Dyn{
|
||||
Dyn: &emptypb.Empty{}}}
|
||||
)
|
||||
|
||||
// Commonly used types.
|
||||
var (
|
||||
Bool = NewPrimitiveType(exprpb.Type_BOOL)
|
||||
Bytes = NewPrimitiveType(exprpb.Type_BYTES)
|
||||
Double = NewPrimitiveType(exprpb.Type_DOUBLE)
|
||||
Int = NewPrimitiveType(exprpb.Type_INT64)
|
||||
Null = &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_Null{
|
||||
Null: structpb.NullValue_NULL_VALUE}}
|
||||
String = NewPrimitiveType(exprpb.Type_STRING)
|
||||
Uint = NewPrimitiveType(exprpb.Type_UINT64)
|
||||
)
|
||||
|
||||
// Well-known types.
|
||||
// TODO: Replace with an abstract type registry.
|
||||
var (
|
||||
Any = NewWellKnownType(exprpb.Type_ANY)
|
||||
Duration = NewWellKnownType(exprpb.Type_DURATION)
|
||||
Timestamp = NewWellKnownType(exprpb.Type_TIMESTAMP)
|
||||
)
|
||||
|
||||
// NewAbstractType creates an abstract type declaration which references a proto
|
||||
// message name and may also include type parameters.
|
||||
func NewAbstractType(name string, paramTypes ...*exprpb.Type) *exprpb.Type {
|
||||
return &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_AbstractType_{
|
||||
AbstractType: &exprpb.Type_AbstractType{
|
||||
Name: name,
|
||||
ParameterTypes: paramTypes}}}
|
||||
}
|
||||
|
||||
// NewFunctionType creates a function invocation contract, typically only used
|
||||
// by type-checking steps after overload resolution.
|
||||
func NewFunctionType(resultType *exprpb.Type,
|
||||
argTypes ...*exprpb.Type) *exprpb.Type {
|
||||
return &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_Function{
|
||||
Function: &exprpb.Type_FunctionType{
|
||||
ResultType: resultType,
|
||||
ArgTypes: argTypes}}}
|
||||
}
|
||||
|
||||
// NewFunction creates a named function declaration with one or more overloads.
|
||||
func NewFunction(name string,
|
||||
overloads ...*exprpb.Decl_FunctionDecl_Overload) *exprpb.Decl {
|
||||
return &exprpb.Decl{
|
||||
Name: name,
|
||||
DeclKind: &exprpb.Decl_Function{
|
||||
Function: &exprpb.Decl_FunctionDecl{
|
||||
Overloads: overloads}}}
|
||||
}
|
||||
|
||||
// NewIdent creates a named identifier declaration with an optional literal
|
||||
// value.
|
||||
//
|
||||
// Literal values are typically only associated with enum identifiers.
|
||||
//
|
||||
// Deprecated: Use NewVar or NewConst instead.
|
||||
func NewIdent(name string, t *exprpb.Type, v *exprpb.Constant) *exprpb.Decl {
|
||||
return &exprpb.Decl{
|
||||
Name: name,
|
||||
DeclKind: &exprpb.Decl_Ident{
|
||||
Ident: &exprpb.Decl_IdentDecl{
|
||||
Type: t,
|
||||
Value: v}}}
|
||||
}
|
||||
|
||||
// NewConst creates a constant identifier with a CEL constant literal value.
|
||||
func NewConst(name string, t *exprpb.Type, v *exprpb.Constant) *exprpb.Decl {
|
||||
return NewIdent(name, t, v)
|
||||
}
|
||||
|
||||
// NewVar creates a variable identifier.
|
||||
func NewVar(name string, t *exprpb.Type) *exprpb.Decl {
|
||||
return NewIdent(name, t, nil)
|
||||
}
|
||||
|
||||
// NewInstanceOverload creates a instance function overload contract.
|
||||
// First element of argTypes is instance.
|
||||
func NewInstanceOverload(id string, argTypes []*exprpb.Type,
|
||||
resultType *exprpb.Type) *exprpb.Decl_FunctionDecl_Overload {
|
||||
return &exprpb.Decl_FunctionDecl_Overload{
|
||||
OverloadId: id,
|
||||
ResultType: resultType,
|
||||
Params: argTypes,
|
||||
IsInstanceFunction: true}
|
||||
}
|
||||
|
||||
// NewListType generates a new list with elements of a certain type.
|
||||
func NewListType(elem *exprpb.Type) *exprpb.Type {
|
||||
return &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_ListType_{
|
||||
ListType: &exprpb.Type_ListType{
|
||||
ElemType: elem}}}
|
||||
}
|
||||
|
||||
// NewMapType generates a new map with typed keys and values.
|
||||
func NewMapType(key *exprpb.Type, value *exprpb.Type) *exprpb.Type {
|
||||
return &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_MapType_{
|
||||
MapType: &exprpb.Type_MapType{
|
||||
KeyType: key,
|
||||
ValueType: value}}}
|
||||
}
|
||||
|
||||
// NewObjectType creates an object type for a qualified type name.
|
||||
func NewObjectType(typeName string) *exprpb.Type {
|
||||
return &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_MessageType{
|
||||
MessageType: typeName}}
|
||||
}
|
||||
|
||||
// NewOverload creates a function overload declaration which contains a unique
|
||||
// overload id as well as the expected argument and result types. Overloads
|
||||
// must be aggregated within a Function declaration.
|
||||
func NewOverload(id string, argTypes []*exprpb.Type,
|
||||
resultType *exprpb.Type) *exprpb.Decl_FunctionDecl_Overload {
|
||||
return &exprpb.Decl_FunctionDecl_Overload{
|
||||
OverloadId: id,
|
||||
ResultType: resultType,
|
||||
Params: argTypes,
|
||||
IsInstanceFunction: false}
|
||||
}
|
||||
|
||||
// NewParameterizedInstanceOverload creates a parametric function instance overload type.
|
||||
func NewParameterizedInstanceOverload(id string,
|
||||
argTypes []*exprpb.Type,
|
||||
resultType *exprpb.Type,
|
||||
typeParams []string) *exprpb.Decl_FunctionDecl_Overload {
|
||||
return &exprpb.Decl_FunctionDecl_Overload{
|
||||
OverloadId: id,
|
||||
ResultType: resultType,
|
||||
Params: argTypes,
|
||||
TypeParams: typeParams,
|
||||
IsInstanceFunction: true}
|
||||
}
|
||||
|
||||
// NewParameterizedOverload creates a parametric function overload type.
|
||||
func NewParameterizedOverload(id string,
|
||||
argTypes []*exprpb.Type,
|
||||
resultType *exprpb.Type,
|
||||
typeParams []string) *exprpb.Decl_FunctionDecl_Overload {
|
||||
return &exprpb.Decl_FunctionDecl_Overload{
|
||||
OverloadId: id,
|
||||
ResultType: resultType,
|
||||
Params: argTypes,
|
||||
TypeParams: typeParams,
|
||||
IsInstanceFunction: false}
|
||||
}
|
||||
|
||||
// NewPrimitiveType creates a type for a primitive value. See the var declarations
|
||||
// for Int, Uint, etc.
|
||||
func NewPrimitiveType(primitive exprpb.Type_PrimitiveType) *exprpb.Type {
|
||||
return &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_Primitive{
|
||||
Primitive: primitive}}
|
||||
}
|
||||
|
||||
// NewTypeType creates a new type designating a type.
|
||||
func NewTypeType(nested *exprpb.Type) *exprpb.Type {
|
||||
if nested == nil {
|
||||
// must set the nested field for a valid oneof option
|
||||
nested = &exprpb.Type{}
|
||||
}
|
||||
return &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_Type{
|
||||
Type: nested}}
|
||||
}
|
||||
|
||||
// NewTypeParamType creates a type corresponding to a named, contextual parameter.
|
||||
func NewTypeParamType(name string) *exprpb.Type {
|
||||
return &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_TypeParam{
|
||||
TypeParam: name}}
|
||||
}
|
||||
|
||||
// NewWellKnownType creates a type corresponding to a protobuf well-known type
|
||||
// value.
|
||||
func NewWellKnownType(wellKnown exprpb.Type_WellKnownType) *exprpb.Type {
|
||||
return &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_WellKnown{
|
||||
WellKnown: wellKnown}}
|
||||
}
|
||||
|
||||
// NewWrapperType creates a wrapped primitive type instance. Wrapped types
|
||||
// are roughly equivalent to a nullable, or optionally valued type.
|
||||
func NewWrapperType(wrapped *exprpb.Type) *exprpb.Type {
|
||||
primitive := wrapped.GetPrimitive()
|
||||
if primitive == exprpb.Type_PRIMITIVE_TYPE_UNSPECIFIED {
|
||||
// TODO: return an error
|
||||
panic("Wrapped type must be a primitive")
|
||||
}
|
||||
return &exprpb.Type{
|
||||
TypeKind: &exprpb.Type_Wrapper{
|
||||
Wrapper: primitive}}
|
||||
}
|
145
vendor/github.com/google/cel-go/checker/decls/scopes.go
generated
vendored
Normal file
145
vendor/github.com/google/cel-go/checker/decls/scopes.go
generated
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package decls
|
||||
|
||||
import exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
|
||||
|
||||
// Scopes represents nested Decl sets where the Scopes value contains a Groups containing all
|
||||
// identifiers in scope and an optional parent representing outer scopes.
|
||||
// Each Groups value is a mapping of names to Decls in the ident and function namespaces.
|
||||
// Lookups are performed such that bindings in inner scopes shadow those in outer scopes.
|
||||
type Scopes struct {
|
||||
parent *Scopes
|
||||
scopes *Group
|
||||
}
|
||||
|
||||
// NewScopes creates a new, empty Scopes.
|
||||
// Some operations can't be safely performed until a Group is added with Push.
|
||||
func NewScopes() *Scopes {
|
||||
return &Scopes{
|
||||
scopes: newGroup(),
|
||||
}
|
||||
}
|
||||
|
||||
// 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{
|
||||
parent: s,
|
||||
scopes: newGroup(),
|
||||
}
|
||||
}
|
||||
|
||||
// Pop returns the parent Scopes value for the current scope, or the current scope if the parent
|
||||
// is nil.
|
||||
func (s *Scopes) Pop() *Scopes {
|
||||
if s.parent != nil {
|
||||
return s.parent
|
||||
}
|
||||
// TODO: Consider whether this should be an error / panic.
|
||||
return s
|
||||
}
|
||||
|
||||
// AddIdent adds the ident Decl in the current scope.
|
||||
// Note: If the name collides with an existing identifier in the scope, the Decl is overwritten.
|
||||
func (s *Scopes) AddIdent(decl *exprpb.Decl) {
|
||||
s.scopes.idents[decl.Name] = decl
|
||||
}
|
||||
|
||||
// FindIdent finds the first ident Decl with a matching name in Scopes, or nil if one cannot be
|
||||
// found.
|
||||
// Note: The search is performed from innermost to outermost.
|
||||
func (s *Scopes) FindIdent(name string) *exprpb.Decl {
|
||||
if ident, found := s.scopes.idents[name]; found {
|
||||
return ident
|
||||
}
|
||||
if s.parent != nil {
|
||||
return s.parent.FindIdent(name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// FindIdentInScope finds the first ident Decl with a matching name in the current Scopes value, or
|
||||
// nil if one does not exist.
|
||||
// Note: The search is only performed on the current scope and does not search outer scopes.
|
||||
func (s *Scopes) FindIdentInScope(name string) *exprpb.Decl {
|
||||
if ident, found := s.scopes.idents[name]; found {
|
||||
return ident
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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) SetFunction(fn *exprpb.Decl) {
|
||||
s.scopes.functions[fn.Name] = fn
|
||||
}
|
||||
|
||||
// FindFunction finds the first function Decl with a matching name in Scopes.
|
||||
// The search is performed from innermost to outermost.
|
||||
// Returns nil if no such function in Scopes.
|
||||
func (s *Scopes) FindFunction(name string) *exprpb.Decl {
|
||||
if fn, found := s.scopes.functions[name]; found {
|
||||
return fn
|
||||
}
|
||||
if s.parent != nil {
|
||||
return s.parent.FindFunction(name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Group is a set of Decls that is pushed on or popped off a Scopes as a unit.
|
||||
// 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),
|
||||
functions: make(map[string]*exprpb.Decl),
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user