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

Interface Expr

common/ast/expr.go:57–117  ·  view source on GitHub ↗

Expr represents the base expression node in a CEL abstract syntax tree. Depending on the `Kind()` value, the Expr may be converted to a concrete expression types as indicated by the `As ` methods.

Source from the content-addressed store, hash-verified

55// Depending on the `Kind()` value, the Expr may be converted to a concrete expression types
56// as indicated by the `As<Kind>` methods.
57type Expr interface {
58 // ID of the expression as it appears in the AST
59 ID() int64
60
61 // Kind of the expression node. See ExprKind for the valid enum values.
62 Kind() ExprKind
63
64 // AsCall adapts the expr into a CallExpr
65 //
66 // The Kind() must be equal to a CallKind for the conversion to be well-defined.
67 AsCall() CallExpr
68
69 // AsComprehension adapts the expr into a ComprehensionExpr.
70 //
71 // The Kind() must be equal to a ComprehensionKind for the conversion to be well-defined.
72 AsComprehension() ComprehensionExpr
73
74 // AsIdent adapts the expr into an identifier string.
75 //
76 // The Kind() must be equal to an IdentKind for the conversion to be well-defined.
77 AsIdent() string
78
79 // AsLiteral adapts the expr into a constant ref.Val.
80 //
81 // The Kind() must be equal to a LiteralKind for the conversion to be well-defined.
82 AsLiteral() ref.Val
83
84 // AsList adapts the expr into a ListExpr.
85 //
86 // The Kind() must be equal to a ListKind for the conversion to be well-defined.
87 AsList() ListExpr
88
89 // AsMap adapts the expr into a MapExpr.
90 //
91 // The Kind() must be equal to a MapKind for the conversion to be well-defined.
92 AsMap() MapExpr
93
94 // AsSelect adapts the expr into a SelectExpr.
95 //
96 // The Kind() must be equal to a SelectKind for the conversion to be well-defined.
97 AsSelect() SelectExpr
98
99 // AsStruct adapts the expr into a StructExpr.
100 //
101 // The Kind() must be equal to a StructKind for the conversion to be well-defined.
102 AsStruct() StructExpr
103
104 // RenumberIDs performs an in-place update of the expression and all of its descendents numeric ids.
105 RenumberIDs(IDGenerator)
106
107 // SetKindCase replaces the contents of the current expression with the contents of the other.
108 //
109 // The SetKindCase takes ownership of any expression instances references within the input Expr.
110 // A shallow copy is made of the Expr value itself, but not a deep one.
111 //
112 // This method should only be used during AST rewrites using temporary Expr values.
113 SetKindCase(Expr)
114

Callers 5

ResidualAstMethod · 0.92
TestAstToProtoFunction · 0.92
TestAstIsCheckedFunction · 0.92
TestExhaustiveEvalFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected