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

Method addMacroCall

parser/helper.go:231–247  ·  view source on GitHub ↗

addMacroCall adds the macro the the MacroCalls map in source info. If a macro has args/subargs/target that are macros, their ID will be stored instead for later self-lookups.

(exprID int64, function string, target ast.Expr, args ...ast.Expr)

Source from the content-addressed store, hash-verified

229// addMacroCall adds the macro the the MacroCalls map in source info. If a macro has args/subargs/target
230// that are macros, their ID will be stored instead for later self-lookups.
231func (p *parserHelper) addMacroCall(exprID int64, function string, target ast.Expr, args ...ast.Expr) {
232 macroArgs := make([]ast.Expr, len(args))
233 for index, arg := range args {
234 macroArgs[index] = p.buildMacroCallArg(arg)
235 }
236 if target == nil {
237 p.sourceInfo.SetMacroCall(exprID, p.exprFactory.NewCall(0, function, macroArgs...))
238 return
239 }
240 macroTarget := target
241 if _, found := p.sourceInfo.GetMacroCall(target.ID()); found {
242 macroTarget = p.exprFactory.NewUnspecifiedExpr(target.ID())
243 } else {
244 macroTarget = p.buildMacroCallArg(target)
245 }
246 p.sourceInfo.SetMacroCall(exprID, p.exprFactory.NewMemberCall(0, function, macroTarget, macroArgs...))
247}
248
249// logicManager compacts logical trees into a more efficient structure which is semantically
250// equivalent with how the logic graph is constructed by the ANTLR parser.

Callers 1

expandMacroMethod · 0.80

Calls 7

buildMacroCallArgMethod · 0.95
GetMacroCallMethod · 0.80
NewCallMethod · 0.65
IDMethod · 0.65
NewUnspecifiedExprMethod · 0.65
NewMemberCallMethod · 0.65
SetMacroCallMethod · 0.45

Tested by

no test coverage detected