MCPcopy Create free account
hub / github.com/cel-expr/cel-go / NewEnv

Function NewEnv

checker/env.go:81–110  ·  view source on GitHub ↗

NewEnv returns a new *Env with the given parameters.

(container *containers.Container, provider types.Provider, opts ...Option)

Source from the content-addressed store, hash-verified

79
80// NewEnv returns a new *Env with the given parameters.
81func NewEnv(container *containers.Container, provider types.Provider, opts ...Option) (*Env, error) {
82 declarations := newScopes()
83 declarations.Push()
84
85 envOptions := &options{}
86 for _, opt := range opts {
87 if err := opt(envOptions); err != nil {
88 return nil, err
89 }
90 }
91 aggLitElemType := dynElementType
92 if envOptions.homogeneousAggregateLiterals {
93 aggLitElemType = homogenousElementType
94 }
95 filteredOverloadIDs := crossTypeNumericComparisonOverloads
96 if envOptions.crossTypeNumericComparisons {
97 filteredOverloadIDs = make(map[string]struct{})
98 }
99 if envOptions.validatedDeclarations != nil {
100 declarations = envOptions.validatedDeclarations.PushInherited()
101 }
102 return &Env{
103 container: container,
104 provider: provider,
105 declarations: declarations,
106 aggLitElemType: aggLitElemType,
107 filteredOverloadIDs: filteredOverloadIDs,
108 jsonFieldNames: envOptions.jsonFieldNames,
109 }, nil
110}
111
112// AddIdents configures the checker with a list of variable declarations.
113//

Callers 15

newTestEnvFunction · 0.92
initCheckerMethod · 0.92
newTestEnvFunction · 0.92
TestCheckFunction · 0.70
BenchmarkCheckFunction · 0.70
TestCheckErrorDataFunction · 0.70
TestCheckInvalidLiteralFunction · 0.70

Calls 3

newScopesFunction · 0.85
PushInheritedMethod · 0.80
PushMethod · 0.45

Tested by 15

newTestEnvFunction · 0.74
newTestEnvFunction · 0.74
TestCheckFunction · 0.56
BenchmarkCheckFunction · 0.56
TestCheckErrorDataFunction · 0.56
TestCheckInvalidLiteralFunction · 0.56
TestVarsInheritanceFunction · 0.56