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

Method FindConstant

eval/compiler/resolver.cc:105–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105absl::optional<cel::Value> Resolver::FindConstant(absl::string_view name,
106 int64_t expr_id) const {
107 auto prefixes = GetPrefixesFor(name);
108 for (const auto& prefix : prefixes) {
109 std::string qualified_name = absl::StrCat(prefix, name);
110 // Attempt to resolve the fully qualified name to a known enum.
111 auto enum_entry = enum_value_map_->find(qualified_name);
112 if (enum_entry != enum_value_map_->end()) {
113 return enum_entry->second;
114 }
115 // Attempt to resolve the fully qualified name to a known type.
116 if (resolve_qualified_type_identifiers_) {
117 auto type_value = type_reflector_.FindType(qualified_name);
118 if (type_value.ok() && type_value->has_value()) {
119 return TypeValue(**type_value);
120 }
121 }
122 }
123
124 if (!resolve_qualified_type_identifiers_ && !absl::StrContains(name, '.')) {
125 auto type_value = type_reflector_.FindType(name);
126
127 if (type_value.ok() && type_value->has_value()) {
128 return TypeValue(**type_value);
129 }
130 }
131 return absl::nullopt;
132}
133
134std::vector<cel::FunctionOverloadReference> Resolver::FindOverloads(
135 absl::string_view name, bool receiver_style,

Callers 2

PostVisitIdentMethod · 0.80
TEST_FFunction · 0.80

Calls 5

TypeValueClass · 0.50
endMethod · 0.45
FindTypeMethod · 0.45
okMethod · 0.45
has_valueMethod · 0.45

Tested by 1

TEST_FFunction · 0.64