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

Method AddVariableConfig

env/config.cc:125–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125absl::Status Config::AddVariableConfig(const VariableConfig& variable_config) {
126 for (const VariableConfig& existing_variable_config : variable_configs_) {
127 if (existing_variable_config.name == variable_config.name) {
128 return absl::AlreadyExistsError(absl::StrCat(
129 "Variable '", variable_config.name, "' is already included."));
130 }
131 }
132 if (variable_config.value.has_value()) {
133 absl::string_view constant_type_name =
134 ConstantKindToTypeName(variable_config.value.kind());
135 if (constant_type_name != variable_config.type_info.name) {
136 return absl::InvalidArgumentError(
137 absl::StrCat("Variable '", variable_config.name, "' has type ",
138 variable_config.type_info.name,
139 " but is assigned a constant value of type ",
140 constant_type_name, "."));
141 }
142 }
143 variable_configs_.push_back(variable_config);
144 return absl::OkStatus();
145}
146
147absl::Status Config::ValidateFunctionConfig(
148 const FunctionConfig& function_config) {

Callers 4

GetExportTestCasesFunction · 0.80
TESTFunction · 0.80
ParseVariableConfigsFunction · 0.80
env_test.ccFile · 0.80

Calls 3

ConstantKindToTypeNameFunction · 0.85
has_valueMethod · 0.45
kindMethod · 0.45

Tested by 2

GetExportTestCasesFunction · 0.64
TESTFunction · 0.64