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

Method addMacroCall

parser/helper.go:227–243  ·  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

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