| 249 | } |
| 250 | |
| 251 | TypePtr SignatureBinder::tryResolveType( |
| 252 | const exec::TypeSignature& typeSignature, |
| 253 | const std::unordered_map<std::string, SignatureVariable>& variables, |
| 254 | const std::unordered_map<std::string, TypePtr>& typeVariablesBindings, |
| 255 | std::unordered_map<std::string, int>& integerVariablesBindings) { |
| 256 | const auto baseName = typeSignature.baseName(); |
| 257 | |
| 258 | if (variables.count(baseName)) { |
| 259 | auto it = typeVariablesBindings.find(baseName); |
| 260 | if (it == typeVariablesBindings.end()) { |
| 261 | return nullptr; |
| 262 | } |
| 263 | return it->second; |
| 264 | } |
| 265 | |
| 266 | // Type is not a variable. |
| 267 | auto typeName = boost::algorithm::to_upper_copy(baseName); |
| 268 | |
| 269 | const auto& params = typeSignature.parameters(); |
| 270 | std::vector<std::string> params_name; |
| 271 | |
| 272 | std::vector<TypeParameter> typeParameters; |
| 273 | for (auto& param : params) { |
| 274 | if (param.rowFieldName().has_value()) { |
| 275 | params_name.emplace_back(param.rowFieldName().value()); |
| 276 | } else { |
| 277 | params_name.emplace_back(""); |
| 278 | } |
| 279 | auto literal = |
| 280 | tryResolveLongLiteral(param, variables, integerVariablesBindings); |
| 281 | if (literal.has_value()) { |
| 282 | typeParameters.push_back(TypeParameter(literal.value())); |
| 283 | continue; |
| 284 | } |
| 285 | |
| 286 | auto type = tryResolveType( |
| 287 | param, variables, typeVariablesBindings, integerVariablesBindings); |
| 288 | if (!type) { |
| 289 | return nullptr; |
| 290 | } |
| 291 | typeParameters.push_back(TypeParameter(type)); |
| 292 | } |
| 293 | |
| 294 | try { |
| 295 | if (auto type = getType(typeName, typeParameters, std::move(params_name))) { |
| 296 | return type; |
| 297 | } |
| 298 | } catch (const std::exception&) { |
| 299 | // TODO Perhaps, modify getType to add suppress-errors flag. |
| 300 | return nullptr; |
| 301 | } |
| 302 | |
| 303 | auto typeKind = tryMapNameToTypeKind(typeName); |
| 304 | if (!typeKind.has_value()) { |
| 305 | return nullptr; |
| 306 | } |
| 307 | |
| 308 | // getType(parameters) function doesn't support OPAQUE type. |