| 130 | }; |
| 131 | |
| 132 | absl::StatusOr<Value> EvaluateInMap(ExecutionFrameBase& frame, |
| 133 | const Value& item, |
| 134 | const MapValue& container) { |
| 135 | switch (item.kind()) { |
| 136 | case ValueKind::kBool: |
| 137 | case ValueKind::kString: |
| 138 | case ValueKind::kInt: |
| 139 | case ValueKind::kUint: |
| 140 | case ValueKind::kDouble: |
| 141 | break; |
| 142 | default: |
| 143 | return cel::ErrorValue( |
| 144 | cel::runtime_internal::CreateNoMatchingOverloadError( |
| 145 | cel::builtin::kIn)); |
| 146 | } |
| 147 | Value result; |
| 148 | CEL_RETURN_IF_ERROR(container.Has(item, frame.descriptor_pool(), |
| 149 | frame.message_factory(), frame.arena(), |
| 150 | &result)); |
| 151 | |
| 152 | if (result.IsTrue()) { |
| 153 | return result; |
| 154 | } |
| 155 | |
| 156 | if (item.IsDouble() || item.IsUint()) { |
| 157 | Number number = item.IsDouble() |
| 158 | ? Number::FromDouble(item.GetDouble().NativeValue()) |
| 159 | : Number::FromUint64(item.GetUint().NativeValue()); |
| 160 | if (number.LosslessConvertibleToInt()) { |
| 161 | CEL_RETURN_IF_ERROR( |
| 162 | container.Has(IntValue(number.AsInt()), frame.descriptor_pool(), |
| 163 | frame.message_factory(), frame.arena(), &result)); |
| 164 | if (result.IsTrue()) { |
| 165 | return result; |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | if (item.IsDouble() || item.IsInt()) { |
| 171 | Number number = item.IsDouble() |
| 172 | ? Number::FromDouble(item.GetDouble().NativeValue()) |
| 173 | : Number::FromInt64(item.GetInt().NativeValue()); |
| 174 | if (number.LosslessConvertibleToUint()) { |
| 175 | CEL_RETURN_IF_ERROR( |
| 176 | container.Has(UintValue(number.AsUint()), frame.descriptor_pool(), |
| 177 | frame.message_factory(), frame.arena(), &result)); |
| 178 | if (result.IsTrue()) { |
| 179 | return result; |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | return BoolValue(false); |
| 185 | } |
| 186 | |
| 187 | absl::StatusOr<Value> EvaluateIn(ExecutionFrameBase& frame, const Value& item, |
| 188 | const AttributeTrail& item_attr, |
no test coverage detected