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

Method Evaluate2

eval/eval/comprehension_step.cc:327–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325}
326
327absl::Status ComprehensionDirectStep::Evaluate2(ExecutionFrameBase& frame,
328 Value& result,
329 AttributeTrail& trail) const {
330 Value range;
331 AttributeTrail range_attr;
332 CEL_RETURN_IF_ERROR(range_->Evaluate(frame, range, range_attr));
333
334 if (frame.unknown_processing_enabled() && range.IsMap()) {
335 if (frame.attribute_utility().CheckForUnknownPartial(range_attr)) {
336 result =
337 frame.attribute_utility().CreateUnknownSet(range_attr.attribute());
338 return absl::OkStatus();
339 }
340 }
341
342 absl_nullability_unknown ValueIteratorPtr range_iter;
343 switch (range.kind()) {
344 case ValueKind::kList: {
345 CEL_ASSIGN_OR_RETURN(range_iter, range.GetList().NewIterator());
346 } break;
347 case ValueKind::kMap: {
348 CEL_ASSIGN_OR_RETURN(range_iter, range.GetMap().NewIterator());
349 } break;
350 case ValueKind::kError:
351 ABSL_FALLTHROUGH_INTENDED;
352 case ValueKind::kUnknown:
353 result = std::move(range);
354 return absl::OkStatus();
355 default:
356 result = cel::ErrorValue(CreateNoMatchingOverloadError("<iter_range>"));
357 return absl::OkStatus();
358 }
359 ABSL_DCHECK(range_iter != nullptr);
360
361 ComprehensionSlots::Slot* accu_slot =
362 frame.comprehension_slots().Get(accu_slot_);
363 ABSL_DCHECK(accu_slot != nullptr);
364
365 {
366 Value accu_init;
367 AttributeTrail accu_init_attr;
368 CEL_RETURN_IF_ERROR(accu_init_->Evaluate(frame, accu_init, accu_init_attr));
369 accu_slot->Set(std::move(accu_init), std::move(accu_init_attr));
370 }
371
372 ComprehensionSlots::Slot* iter_slot =
373 frame.comprehension_slots().Get(iter_slot_);
374 ABSL_DCHECK(iter_slot != nullptr);
375 iter_slot->Set();
376
377 ComprehensionSlots::Slot* iter2_slot =
378 frame.comprehension_slots().Get(iter2_slot_);
379 ABSL_DCHECK(iter2_slot != nullptr);
380 iter2_slot->Set();
381
382 Value condition;
383 AttributeTrail condition_attr;
384 bool should_skip_result = false;

Callers

nothing calls this directly

Calls 15

ErrorValueFunction · 0.85
attributeMethod · 0.80
IncrementIterationsMethod · 0.80
mutable_attributeMethod · 0.80
CheckForUnknownExactMethod · 0.80
mutable_valueMethod · 0.80
HasEnoughMethod · 0.80
JumpToMethod · 0.80
SwapAndPopMethod · 0.80
ClearSlotMethod · 0.80

Tested by

no test coverage detected