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

Method CompileOptions

ext/comprehensions.go:192–235  ·  view source on GitHub ↗

CompileOptions implements the cel.Library interface method.

()

Source from the content-addressed store, hash-verified

190
191// CompileOptions implements the cel.Library interface method.
192func (*compreV2Lib) CompileOptions() []cel.EnvOption {
193 kType := cel.TypeParamType("K")
194 vType := cel.TypeParamType("V")
195 mapKVType := cel.MapType(kType, vType)
196 opts := []cel.EnvOption{
197 cel.Macros(
198 cel.ReceiverMacro("all", 3, quantifierAll),
199 cel.ReceiverMacro("exists", 3, quantifierExists),
200 cel.ReceiverMacro("existsOne", 3, quantifierExistsOne),
201 cel.ReceiverMacro("exists_one", 3, quantifierExistsOne),
202 cel.ReceiverMacro("transformList", 3, transformList),
203 cel.ReceiverMacro("transformList", 4, transformList),
204 cel.ReceiverMacro("transformMap", 3, transformMap),
205 cel.ReceiverMacro("transformMap", 4, transformMap),
206 cel.ReceiverMacro("transformMapEntry", 3, transformMapEntry),
207 cel.ReceiverMacro("transformMapEntry", 4, transformMapEntry),
208 ),
209 cel.Function(mapInsert,
210 cel.Overload(mapInsertOverloadKeyValue, []*cel.Type{mapKVType, kType, vType}, mapKVType,
211 cel.FunctionBinding(func(args ...ref.Val) ref.Val {
212 m := args[0].(traits.Mapper)
213 k := args[1]
214 v := args[2]
215 return types.InsertMapKeyValue(m, k, v)
216 })),
217 cel.Overload(mapInsertOverloadMap, []*cel.Type{mapKVType, mapKVType}, mapKVType,
218 cel.BinaryBinding(func(targetMap, updateMap ref.Val) ref.Val {
219 tm := targetMap.(traits.Mapper)
220 um := updateMap.(traits.Mapper)
221 umIt := um.Iterator()
222 for umIt.HasNext() == types.True {
223 k := umIt.Next()
224 updateOrErr := types.InsertMapKeyValue(tm, k, um.Get(k))
225 if types.IsError(updateOrErr) {
226 return updateOrErr
227 }
228 tm = updateOrErr.(traits.Mapper)
229 }
230 return tm
231 })),
232 ),
233 }
234 return opts
235}
236
237// ProgramOptions implements the cel.Library interface method
238func (*compreV2Lib) ProgramOptions() []cel.ProgramOption {

Callers

nothing calls this directly

Calls 12

MacrosFunction · 0.92
ReceiverMacroFunction · 0.92
FunctionFunction · 0.92
OverloadFunction · 0.92
FunctionBindingFunction · 0.92
InsertMapKeyValueFunction · 0.92
BinaryBindingFunction · 0.92
IsErrorFunction · 0.92
IteratorMethod · 0.65
HasNextMethod · 0.65
NextMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected