Creates merged UnknownAttributeSet. Merges together attributes from UnknownAttributeSets found in the args collection, attributes from attr that match unknown pattern patterns, and attributes from initial_set (if initial_set is not null). Returns pointer to merged set or nullptr, if there were no sets to merge.
| 170 | // (if initial_set is not null). |
| 171 | // Returns pointer to merged set or nullptr, if there were no sets to merge. |
| 172 | absl::optional<UnknownValue> AttributeUtility::IdentifyAndMergeUnknowns( |
| 173 | absl::Span<const cel::Value> args, absl::Span<const AttributeTrail> attrs, |
| 174 | bool use_partial) const { |
| 175 | absl::optional<UnknownSet> result_set; |
| 176 | |
| 177 | // Identify new unknowns by attribute patterns. |
| 178 | cel::AttributeSet attr_set = CheckForUnknowns(attrs, use_partial); |
| 179 | if (!attr_set.empty()) { |
| 180 | result_set.emplace(std::move(attr_set)); |
| 181 | } |
| 182 | |
| 183 | // merge down existing unknown sets |
| 184 | absl::optional<UnknownValue> arg_unknowns = MergeUnknowns(args); |
| 185 | |
| 186 | if (!result_set.has_value()) { |
| 187 | // No new unknowns so no need to check for presence of existing unknowns -- |
| 188 | // just forward. |
| 189 | return arg_unknowns; |
| 190 | } |
| 191 | |
| 192 | if (arg_unknowns.has_value()) { |
| 193 | cel::base_internal::UnknownSetAccess::Add( |
| 194 | *result_set, UnknownSet((*arg_unknowns).attribute_set(), |
| 195 | (*arg_unknowns).function_result_set())); |
| 196 | } |
| 197 | |
| 198 | return UnknownValue(cel::Unknown(result_set->unknown_attributes(), |
| 199 | result_set->unknown_function_results())); |
| 200 | } |
| 201 | |
| 202 | UnknownValue AttributeUtility::CreateUnknownSet(cel::Attribute attr) const { |
| 203 | return UnknownValue(cel::Unknown(AttributeSet({std::move(attr)}))); |
no test coverage detected