MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / evalExpr

Method evalExpr

pkg/filter/ql/function.go:409–440  ·  view source on GitHub ↗
(e any, useCallValuer bool, valuers ...Valuer)

Source from the content-addressed store, hash-verified

407}
408
409func (f *Foreach) evalExpr(e any, useCallValuer bool, valuers ...Valuer) bool {
410 var valuer ValuerEval
411
412 if useCallValuer {
413 callValuerMap := make(map[string]interface{})
414 for _, v := range valuers {
415 if m, ok := v.(MapValuer); ok {
416 maps.Copy(callValuerMap, m)
417 }
418 }
419 valuer = ValuerEval{Valuer: MultiValuer(append([]Valuer{FunctionValuer{callValuerMap}}, valuers...)...)}
420 } else {
421 valuer = ValuerEval{Valuer: MultiValuer(valuers...)}
422 }
423
424 switch expr := e.(type) {
425 case *BinaryExpr:
426 v, ok := valuer.Eval(expr).(bool)
427 if !ok {
428 return false
429 }
430 return v
431 case *NotExpr:
432 v, ok := valuer.Eval(expr).(bool)
433 if !ok {
434 return false
435 }
436 return v
437 }
438
439 return false
440}
441
442// stringMapValuer returns the map valuer composed of primitive string values.
443func (f *Foreach) stringMapValuer(v *BareBoundVariableLiteral, s string) MapValuer {

Callers 1

CallMethod · 0.95

Calls 3

EvalMethod · 0.95
MultiValuerFunction · 0.85
CopyMethod · 0.80

Tested by

no test coverage detected