Skip to content

Commit

Permalink
[WIP] Inliner and constant folder
Browse files Browse the repository at this point in the history
  • Loading branch information
TristonianJones committed Aug 19, 2023
1 parent 1a6373d commit ec77e3c
Show file tree
Hide file tree
Showing 10 changed files with 1,311 additions and 3 deletions.
3 changes: 3 additions & 0 deletions cel/BUILD.bazel
Expand Up @@ -10,9 +10,11 @@ go_library(
"cel.go",
"decls.go",
"env.go",
"folding.go",
"io.go",
"library.go",
"macro.go",
"optimizer.go",
"options.go",
"program.go",
"validator.go",
Expand Down Expand Up @@ -56,6 +58,7 @@ go_test(
"cel_test.go",
"decls_test.go",
"env_test.go",
"folding_test.go",
"io_test.go",
"validator_test.go",
],
Expand Down
8 changes: 8 additions & 0 deletions cel/env.go
Expand Up @@ -43,6 +43,9 @@ type Ast struct {
}

// Expr returns the proto serializable instance of the parsed/checked expression.
//
// Deprecated: prefer cel.AstToCheckedExpr() or cel.AstToParsedExpr() and call GetExpr()
// the result instead.
func (ast *Ast) Expr() *exprpb.Expr {
if ast == nil {
return nil
Expand Down Expand Up @@ -221,6 +224,11 @@ func (e *Env) Check(ast *Ast) (*Ast, *Issues) {
source: ast.Source(),
impl: checked}

// Avoid creating a validator config if it's not needed.
if len(e.validators) == 0 {
return ast, nil
}

// Generate a validator configuration from the set of configured validators.
vConfig := newValidatorConfig()
for _, v := range e.validators {
Expand Down

0 comments on commit ec77e3c

Please sign in to comment.