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

Class FlatExpressionEvaluatorState

eval/eval/evaluator_core.h:106–155  ·  view source on GitHub ↗

Class that wraps the state that needs to be allocated for expression evaluation. This can be reused to save on allocations.

Source from the content-addressed store, hash-verified

104// Class that wraps the state that needs to be allocated for expression
105// evaluation. This can be reused to save on allocations.
106class FlatExpressionEvaluatorState {
107 public:
108 FlatExpressionEvaluatorState(
109 size_t value_stack_size, size_t comprehension_slot_count,
110 const cel::TypeProvider& type_provider,
111 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
112 google::protobuf::MessageFactory* absl_nonnull message_factory,
113 google::protobuf::Arena* absl_nonnull arena)
114 : value_stack_(value_stack_size),
115 // We currently use comprehension_slot_count because it is less of an
116 // over estimate than value_stack_size. In future we should just
117 // calculate the correct capacity.
118 iterator_stack_(comprehension_slot_count),
119 comprehension_slots_(comprehension_slot_count),
120 type_provider_(type_provider),
121 descriptor_pool_(descriptor_pool),
122 message_factory_(message_factory),
123 arena_(arena) {}
124
125 void Reset();
126
127 EvaluatorStack& value_stack() { return value_stack_; }
128
129 cel::runtime_internal::IteratorStack& iterator_stack() {
130 return iterator_stack_;
131 }
132
133 ComprehensionSlots& comprehension_slots() { return comprehension_slots_; }
134
135 const cel::TypeProvider& type_provider() { return type_provider_; }
136
137 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool() {
138 return descriptor_pool_;
139 }
140
141 google::protobuf::MessageFactory* absl_nonnull message_factory() {
142 return message_factory_;
143 }
144
145 google::protobuf::Arena* absl_nonnull arena() { return arena_; }
146
147 private:
148 EvaluatorStack value_stack_;
149 cel::runtime_internal::IteratorStack iterator_stack_;
150 ComprehensionSlots comprehension_slots_;
151 const cel::TypeProvider& type_provider_;
152 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool_;
153 google::protobuf::MessageFactory* absl_nonnull message_factory_;
154 google::protobuf::Arena* absl_nonnull arena_;
155};
156
157// Context needed for evaluation. This is sufficient for supporting
158// recursive evaluation, but stack machine programs require an

Callers 1

MakeEvaluatorStateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected