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

Method SetKindCase

common/ast/expr.go:392–456  ·  view source on GitHub ↗
(other Expr)

Source from the content-addressed store, hash-verified

390}
391
392func (e *expr) SetKindCase(other Expr) {
393 if e == nil {
394 return
395 }
396 if other == nil {
397 e.exprKindCase = nil
398 return
399 }
400 switch other.Kind() {
401 case CallKind:
402 c := other.AsCall()
403 e.exprKindCase = &baseCallExpr{
404 function: c.FunctionName(),
405 target: c.Target(),
406 args: c.Args(),
407 isMember: c.IsMemberFunction(),
408 }
409 case ComprehensionKind:
410 c := other.AsComprehension()
411 e.exprKindCase = &baseComprehensionExpr{
412 iterRange: c.IterRange(),
413 iterVar: c.IterVar(),
414 iterVar2: c.IterVar2(),
415 accuVar: c.AccuVar(),
416 accuInit: c.AccuInit(),
417 loopCond: c.LoopCondition(),
418 loopStep: c.LoopStep(),
419 result: c.Result(),
420 }
421 case IdentKind:
422 e.exprKindCase = baseIdentExpr(other.AsIdent())
423 case ListKind:
424 l := other.AsList()
425 optIndexMap := make(map[int32]struct{}, len(l.OptionalIndices()))
426 for _, idx := range l.OptionalIndices() {
427 optIndexMap[idx] = struct{}{}
428 }
429 e.exprKindCase = &baseListExpr{
430 elements: l.Elements(),
431 optIndices: l.OptionalIndices(),
432 optIndexMap: optIndexMap,
433 }
434 case LiteralKind:
435 e.exprKindCase = &baseLiteral{Val: other.AsLiteral()}
436 case MapKind:
437 e.exprKindCase = &baseMapExpr{
438 entries: other.AsMap().Entries(),
439 }
440 case SelectKind:
441 s := other.AsSelect()
442 e.exprKindCase = &baseSelectExpr{
443 operand: s.Operand(),
444 field: s.FieldName(),
445 testOnly: s.IsTestOnly(),
446 }
447 case StructKind:
448 s := other.AsStruct()
449 e.exprKindCase = &baseStructExpr{

Callers

nothing calls this directly

Calls 15

baseIdentExprTypeAlias · 0.85
KindMethod · 0.65
AsCallMethod · 0.65
FunctionNameMethod · 0.65
TargetMethod · 0.65
ArgsMethod · 0.65
IsMemberFunctionMethod · 0.65
AsComprehensionMethod · 0.65
IterRangeMethod · 0.65
IterVarMethod · 0.65
IterVar2Method · 0.65
AccuVarMethod · 0.65

Tested by

no test coverage detected