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

Method Evaluate1Unknown

eval/eval/comprehension_step.cc:212–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212absl::StatusOr<bool> ComprehensionDirectStep::Evaluate1Unknown(
213 ExecutionFrameBase& frame, IterableKind range_iter_kind,
214 const AttributeTrail& range_iter_attr,
215 ValueIterator* absl_nonnull range_iter,
216 ComprehensionSlots::Slot* absl_nonnull accu_slot,
217 ComprehensionSlots::Slot* absl_nonnull iter_slot, Value& result,
218 AttributeTrail& trail) const {
219 Value condition;
220 AttributeTrail condition_attr;
221 Value key_or_value;
222 Value* key;
223 Value* value;
224
225 switch (range_iter_kind) {
226 case IterableKind::kList:
227 key = &key_or_value;
228 value = iter_slot->mutable_value();
229 break;
230 case IterableKind::kMap:
231 key = iter_slot->mutable_value();
232 value = nullptr;
233 break;
234 default:
235 ABSL_UNREACHABLE();
236 }
237 while (true) {
238 CEL_ASSIGN_OR_RETURN(bool ok, range_iter->Next2(frame.descriptor_pool(),
239 frame.message_factory(),
240 frame.arena(), key, value));
241 if (!ok) {
242 break;
243 }
244 CEL_RETURN_IF_ERROR(frame.IncrementIterations());
245 *iter_slot->mutable_attribute() =
246 range_iter_attr.Step(AttributeQualifierFromValue(*key));
247 if (frame.attribute_utility().CheckForUnknownExact(
248 iter_slot->attribute())) {
249 *iter_slot->mutable_value() = frame.attribute_utility().CreateUnknownSet(
250 iter_slot->attribute().attribute());
251 }
252
253 // Evaluate the loop condition.
254 CEL_RETURN_IF_ERROR(condition_->Evaluate(frame, condition, condition_attr));
255
256 switch (condition.kind()) {
257 case ValueKind::kBool:
258 break;
259 case ValueKind::kError:
260 ABSL_FALLTHROUGH_INTENDED;
261 case ValueKind::kUnknown:
262 result = std::move(condition);
263 return true;
264 default:
265 result =
266 cel::ErrorValue(CreateNoMatchingOverloadError("<loop_condition>"));
267 return true;
268 }
269

Callers

nothing calls this directly

Calls 13

ErrorValueFunction · 0.85
mutable_valueMethod · 0.80
IncrementIterationsMethod · 0.80
mutable_attributeMethod · 0.80
CheckForUnknownExactMethod · 0.80
attributeMethod · 0.80
StepMethod · 0.45
CreateUnknownSetMethod · 0.45
EvaluateMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected