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

Method NewHasMacro

cel/optimizer.go:442–449  ·  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

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

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