MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / FlatExpression

Class FlatExpression

eval/eval/evaluator_core.h:438–512  ·  view source on GitHub ↗

A flattened representation of the input CEL AST.

Source from the content-addressed store, hash-verified

436
437// A flattened representation of the input CEL AST.
438class FlatExpression {
439 public:
440 // path is flat execution path that is based upon the flattened AST tree
441 // type_provider is the configured type system that should be used for
442 // value creation in evaluation
443 FlatExpression(ExecutionPath path, size_t comprehension_slots_size,
444 const cel::TypeProvider& type_provider,
445 const cel::RuntimeOptions& options,
446 absl_nullable std::shared_ptr<google::protobuf::Arena> arena = nullptr)
447 : path_(std::move(path)),
448 subexpressions_({path_}),
449 comprehension_slots_size_(comprehension_slots_size),
450 type_provider_(type_provider),
451 options_(options),
452 arena_(std::move(arena)) {}
453
454 FlatExpression(ExecutionPath path,
455 std::vector<ExecutionPathView> subexpressions,
456 size_t comprehension_slots_size,
457 const cel::TypeProvider& type_provider,
458 const cel::RuntimeOptions& options,
459 absl_nullable std::shared_ptr<google::protobuf::Arena> arena = nullptr)
460 : path_(std::move(path)),
461 subexpressions_(std::move(subexpressions)),
462 comprehension_slots_size_(comprehension_slots_size),
463 type_provider_(type_provider),
464 options_(options),
465 arena_(std::move(arena)) {}
466
467 // Move-only
468 FlatExpression(FlatExpression&&) = default;
469 FlatExpression& operator=(FlatExpression&&) = delete;
470
471 // Create new evaluator state instance with the configured options and type
472 // provider.
473 FlatExpressionEvaluatorState MakeEvaluatorState(
474 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
475 google::protobuf::MessageFactory* absl_nonnull message_factory,
476 google::protobuf::Arena* absl_nonnull arena) const;
477
478 // Evaluate the expression.
479 //
480 // A status may be returned if an unexpected error occurs. Recoverable errors
481 // will be represented as a cel::ErrorValue result.
482 //
483 // If the listener is not empty, it will be called after each evaluation step
484 // that correlates to an AST node. The value passed to the will be the top of
485 // the evaluation stack, corresponding to the result of the subexpression.
486 absl::StatusOr<cel::Value> EvaluateWithCallback(
487 const cel::ActivationInterface& activation,
488 const cel::EmbedderContext* absl_nullable embedder_context,
489 EvaluationListener listener, FlatExpressionEvaluatorState& state) const;
490
491 const ExecutionPath& path() const { return path_; }
492
493 absl::Span<const ExecutionPathView> subexpressions() const {
494 return subexpressions_;
495 }

Callers 15

CreateExpressionImplMethod · 0.85
MakeStackMachinePathFunction · 0.85
TEST_PFunction · 0.85
TESTFunction · 0.85
RunExpressionFunction · 0.85
TESTFunction · 0.85
RunExpressionMethod · 0.85
TEST_FFunction · 0.85
TEST_PFunction · 0.85

Calls

no outgoing calls

Tested by 15

MakeStackMachinePathFunction · 0.68
TEST_PFunction · 0.68
TESTFunction · 0.68
RunExpressionFunction · 0.68
TESTFunction · 0.68
RunExpressionMethod · 0.68
TEST_FFunction · 0.68
TEST_PFunction · 0.68
EvaluateAttributeHelperFunction · 0.68
TESTFunction · 0.68