MCPcopy
hub / github.com/TecharoHQ/anubis / Compile

Function Compile

lib/policy/expressions/environment.go:237–255  ·  view source on GitHub ↗

Compile takes CEL environment and syntax tree then emits an optimized Program for execution.

(env *cel.Env, src string)

Source from the content-addressed store, hash-verified

235// Compile takes CEL environment and syntax tree then emits an optimized
236// Program for execution.
237func Compile(env *cel.Env, src string) (cel.Program, error) {
238 intermediate, iss := env.Compile(src)
239 if iss != nil {
240 return nil, iss.Err()
241 }
242
243 ast, iss := env.Check(intermediate)
244 if iss != nil {
245 return nil, iss.Err()
246 }
247
248 return env.Program(
249 ast,
250 cel.EvalOptions(
251 // optimize regular expressions right now instead of on the fly
252 cel.OptOptimize,
253 ),
254 )
255}

Callers 5

NewCELCheckerFunction · 0.92
TestBotEnvironmentFunction · 0.85
TestThresholdEnvironmentFunction · 0.85
TestNewEnvironmentFunction · 0.85

Calls 1

CheckMethod · 0.65

Tested by 3

TestBotEnvironmentFunction · 0.68
TestThresholdEnvironmentFunction · 0.68
TestNewEnvironmentFunction · 0.68