MCPcopy Create free account
hub / github.com/bytedance/bolt / validate

Function validate

bolt/expression/FunctionSignature.cpp:157–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157void validate(
158 const std::unordered_map<std::string, SignatureVariable>& variables,
159 const TypeSignature& returnType,
160 const std::vector<TypeSignature>& argumentTypes,
161 const std::vector<bool>& constantArguments) {
162 std::unordered_set<std::string> usedVariables;
163 // Validate the argument types.
164 for (const auto& arg : argumentTypes) {
165 // Is base type a type parameter or a built in type ?
166 validateBaseTypeAndCollectTypeParams(variables, arg, usedVariables, false);
167 }
168
169 // All type variables should appear in the inputs arguments.
170 for (auto& [name, variable] : variables) {
171 if (variable.isTypeParameter()) {
172 BOLT_USER_CHECK(
173 usedVariables.count(name),
174 "Some type variables are not used in the inputs");
175 }
176 }
177
178 validateBaseTypeAndCollectTypeParams(
179 variables, returnType, usedVariables, true);
180
181 BOLT_USER_CHECK_EQ(
182 usedVariables.size(),
183 variables.size(),
184 "Some integer variables are not used");
185
186 BOLT_USER_CHECK_EQ(
187 argumentTypes.size(),
188 constantArguments.size(),
189 "Argument types size is not equal to constant flags");
190}
191
192} // namespace
193

Callers 15

FunctionSignatureMethod · 0.70
setInternalStateMethod · 0.50
validateMethod · 0.50
validateMethod · 0.50
validateMethod · 0.50
validateMethod · 0.50
validateMethod · 0.50
validateMethod · 0.50
TEST_FFunction · 0.50
TEST_FFunction · 0.50
testMapWriterFunction · 0.50

Calls 4

isTypeParameterMethod · 0.80
countMethod · 0.45
sizeMethod · 0.45

Tested by 7

TEST_FFunction · 0.40
TEST_FFunction · 0.40
testMapWriterFunction · 0.40
testMapWriterRowFunction · 0.40
TEST_FFunction · 0.40
TEST_FFunction · 0.40
TEST_PFunction · 0.40