Documentation ¶
Overview ¶
Package checker defines functions to type-checked a parsed expression against a set of identifier and function declarations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
func Check(parsedExpr *exprpb.ParsedExpr, source common.Source, env *Env) (*exprpb.CheckedExpr, *common.Errors)
Check performs type checking, giving a typed AST. The input is a ParsedExpr proto and an env which encapsulates type binding of variables, declarations of built-in functions, descriptions of protocol buffers, and a registry for errors. Returns a CheckedExpr proto, which might not be usable if there are errors in the error registry.
func FormatCheckedType ¶
FormatCheckedType converts a type message into a string representation.
func Print ¶
func Print(e *exprpb.Expr, checks *exprpb.CheckedExpr) string
Print returns a string representation of the Expr message, annotated with types from the CheckedExpr. The Expr must be a sub-expression embedded in the CheckedExpr.
func StandardDeclarations ¶
StandardDeclarations returns the Decls for all functions and constants in the evaluator.
Types ¶
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env is the environment for type checking. It consists of a Packager, a Type Provider, declarations, and collection of errors encountered during checking.
func NewEnv ¶
func NewEnv(packager packages.Packager, provider ref.TypeProvider) *Env
NewEnv returns a new *Env with the given parameters.
func NewStandardEnv ¶
func NewStandardEnv(packager packages.Packager, provider ref.TypeProvider) *Env
NewStandardEnv returns a new *Env with the given params plus standard declarations.
func (*Env) Add ¶
Add adds new Decl protos to the Env. Returns an error for identifier redeclarations.
func (*Env) EnableDynamicAggregateLiterals ¶
EnableDynamicAggregateLiterals detmerines whether list and map literals may support mixed element types at check-time. This does not preclude the presence of a dynamic list or map somewhere in the CEL evaluation process.
func (*Env) LookupFunction ¶
LookupFunction returns a Decl proto for typeName as a function in env. Returns nil if no such function is found in env.