| 75 | } |
| 76 | |
| 77 | std::vector<const CelFunction*> CelFunctionRegistry::FindOverloads( |
| 78 | absl::string_view name, bool receiver_style, |
| 79 | const std::vector<CelValue::Type>& types) const { |
| 80 | std::vector<cel::FunctionOverloadReference> matched_funcs = |
| 81 | modern_registry_.FindStaticOverloads(name, receiver_style, types); |
| 82 | |
| 83 | // For backwards compatibility, lazily initialize a legacy CEL function |
| 84 | // if required. |
| 85 | // The registry should remain add-only until migration to the new type is |
| 86 | // complete, so this should work whether the function was introduced via |
| 87 | // the modern registry or the old registry wrapping a modern instance. |
| 88 | std::vector<const CelFunction*> results; |
| 89 | results.reserve(matched_funcs.size()); |
| 90 | |
| 91 | { |
| 92 | absl::MutexLock lock(mu_); |
| 93 | for (cel::FunctionOverloadReference entry : matched_funcs) { |
| 94 | std::unique_ptr<CelFunction>& legacy_impl = |
| 95 | functions_[&entry.implementation]; |
| 96 | |
| 97 | if (legacy_impl == nullptr) { |
| 98 | legacy_impl = std::make_unique<ProxyToModernCelFunction>( |
| 99 | entry.descriptor, entry.implementation); |
| 100 | } |
| 101 | results.push_back(legacy_impl.get()); |
| 102 | } |
| 103 | } |
| 104 | return results; |
| 105 | } |
| 106 | |
| 107 | std::vector<const CelFunctionDescriptor*> |
| 108 | CelFunctionRegistry::FindLazyOverloads( |