(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr)
| 166 | } |
| 167 | |
| 168 | func celBind(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *cel.Error) { |
| 169 | if !macroTargetMatchesNamespace(celNamespace, target) { |
| 170 | return nil, nil |
| 171 | } |
| 172 | varIdent := args[0] |
| 173 | varName := "" |
| 174 | switch varIdent.Kind() { |
| 175 | case ast.IdentKind: |
| 176 | varName = varIdent.AsIdent() |
| 177 | default: |
| 178 | return nil, mef.NewError(varIdent.ID(), "cel.bind() variable names must be simple identifiers") |
| 179 | } |
| 180 | varInit := args[1] |
| 181 | resultExpr := args[2] |
| 182 | return mef.NewComprehension( |
| 183 | mef.NewList(), |
| 184 | unusedIterVar, |
| 185 | varName, |
| 186 | varInit, |
| 187 | mef.NewLiteral(types.False), |
| 188 | mef.NewIdent(varName), |
| 189 | resultExpr, |
| 190 | ), nil |
| 191 | } |
| 192 | |
| 193 | func newDynamicBlock(slotExprs []interpreter.InterpretableV2, expr interpreter.InterpretableV2) interpreter.InterpretableV2 { |
| 194 | bs := &dynamicBlock{ |
nothing calls this directly
no test coverage detected