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

Method NewHasMacro

cel/optimizer.go:436–443  ·  view source on GitHub ↗

NewHasMacro generates a test-only select expression to be included within an AST and an unexpanded has() macro call signature to be inserted into the source info macro call metadata.

(macroID int64, s ast.Expr)

Source from the content-addressed store, hash-verified

434// NewHasMacro generates a test-only select expression to be included within an AST and an unexpanded
435// has() macro call signature to be inserted into the source info macro call metadata.
436func (opt *optimizerExprFactory) NewHasMacro(macroID int64, s ast.Expr) (astExpr, macroExpr ast.Expr) {
437 sel := s.AsSelect()
438 astExpr = opt.fac.NewPresenceTest(macroID, sel.Operand(), sel.FieldName())
439 macroExpr = opt.fac.NewCall(0, "has",
440 opt.NewSelect(opt.fac.CopyExpr(sel.Operand()), sel.FieldName()))
441 opt.sanitizeMacro(macroID, macroExpr)
442 return
443}
444
445// NewSelect creates a select expression where a field value is selected from an operand.
446//

Callers 2

OptimizeMethod · 0.80
rewritePresenceExprMethod · 0.80

Calls 8

NewSelectMethod · 0.95
sanitizeMacroMethod · 0.95
AsSelectMethod · 0.65
NewPresenceTestMethod · 0.65
OperandMethod · 0.65
FieldNameMethod · 0.65
NewCallMethod · 0.65
CopyExprMethod · 0.65

Tested by 1

OptimizeMethod · 0.64