| 225 | |
| 226 | |
| 227 | void SymbolRuleSet::matchQuerySymbolNumber(const Map& other_map) |
| 228 | { |
| 229 | auto findMatchingSymbol = [&other_map](const Symbol* original, auto compare)->const Symbol* |
| 230 | { |
| 231 | for (int k = 0; k < other_map.getNumSymbols(); ++k) |
| 232 | { |
| 233 | auto other_symbol = other_map.getSymbol(k); |
| 234 | if ((original->*compare)(other_symbol) |
| 235 | && Symbol::areTypesCompatible(original->getType(), other_symbol->getType())) |
| 236 | { |
| 237 | return other_symbol; |
| 238 | } |
| 239 | } |
| 240 | return nullptr; |
| 241 | }; |
| 242 | |
| 243 | for (auto& item : *this) |
| 244 | { |
| 245 | if (item.query.getOperator() != ObjectQuery::OperatorSymbol) |
| 246 | continue; |
| 247 | |
| 248 | auto original = item.query.symbolOperand(); |
| 249 | if (!original) |
| 250 | continue; |
| 251 | |
| 252 | auto candidate = findMatchingSymbol(original, &Symbol::numberEquals); |
| 253 | if (!candidate) |
| 254 | { |
| 255 | candidate = findMatchingSymbol(original, &Symbol::numberEqualsRelaxed); |
| 256 | } |
| 257 | if (candidate != item.symbol) |
| 258 | { |
| 259 | if (candidate) |
| 260 | { |
| 261 | item.symbol = candidate; |
| 262 | item.type = SymbolRule::AutomaticAssignment; |
| 263 | } |
| 264 | else |
| 265 | { |
| 266 | item.type = SymbolRule::NoAssignment; |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | |
| 273 |
no test coverage detected