| 427 | } |
| 428 | |
| 429 | SolverConfiguration SolverConfiguration::loadLegacy(const QJsonDocument &json, QStringList& warnings) |
| 430 | { |
| 431 | auto sco = json.object(); |
| 432 | |
| 433 | Solver* solver = nullptr; |
| 434 | try { |
| 435 | solver = &Solver::lookup(sco["id"].toString(), sco["version"].toString(), false); |
| 436 | } catch (Exception& e) { |
| 437 | warnings << e.message(); |
| 438 | warnings << "Using default solver instead."; |
| 439 | solver = MznDriver::get().defaultSolver(); |
| 440 | } |
| 441 | |
| 442 | if (solver == nullptr) { |
| 443 | throw ConfigError("Failed to load fallback solver."); |
| 444 | } |
| 445 | |
| 446 | SolverConfiguration newSc(*solver); |
| 447 | // if (sco["name"].isString()) { |
| 448 | // newSc.name = sco["name"].toString(); |
| 449 | // } |
| 450 | if (sco["timeLimit"].isDouble()) { |
| 451 | newSc.timeLimit = sco["timeLimit"].toInt(); |
| 452 | } |
| 453 | // if (sco["defaultBehavior"].isBool()) { |
| 454 | // newSc.defaultBehaviour = sco["defaultBehavior"].toBool(); |
| 455 | // } |
| 456 | if (sco["printIntermediate"].isBool()) { |
| 457 | newSc.printIntermediate = sco["printIntermediate"].toBool(); |
| 458 | } |
| 459 | if (sco["stopAfter"].isDouble()) { |
| 460 | newSc.numSolutions = sco["stopAfter"].toInt(); |
| 461 | } |
| 462 | if (sco["verboseFlattening"].isBool()) { |
| 463 | newSc.verboseCompilation = sco["verboseFlattening"].toBool(); |
| 464 | } |
| 465 | if (sco["flatteningStats"].isBool()) { |
| 466 | newSc.compilationStats = sco["flatteningStats"].toBool(); |
| 467 | } |
| 468 | if (sco["optimizationLevel"].isDouble()) { |
| 469 | newSc.optimizationLevel = sco["optimizationLevel"].toInt(); |
| 470 | } |
| 471 | if (sco["additionalData"].isString() && !sco["additionalData"].toString().isEmpty()) { |
| 472 | newSc.additionalData << sco["additionalData"].toString(); |
| 473 | } |
| 474 | if (sco["additionalCompilerCommandline"].isString() && !sco["additionalCompilerCommandline"].toString().isEmpty()) { |
| 475 | parseArgList(sco["additionalCompilerCommandline"].toString(), newSc.extraOptions); |
| 476 | } |
| 477 | if (sco["nThreads"].isDouble()) { |
| 478 | newSc.numThreads = sco["nThreads"].toInt(); |
| 479 | } |
| 480 | if (sco["randomSeed"].isDouble()) { |
| 481 | newSc.randomSeed = sco["randomSeed"].toDouble(); |
| 482 | } |
| 483 | if (sco["solverFlags"].isString() && !sco["solverFlags"].toString().isEmpty()) { |
| 484 | parseArgList(sco["solverFlags"].toString(), newSc.solverBackendOptions); |
| 485 | } |
| 486 | if (sco["freeSearch"].isBool()) { |
nothing calls this directly
no test coverage detected