| 155 | } |
| 156 | |
| 157 | void 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 | |