| 1338 | } |
| 1339 | |
| 1340 | StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast) |
| 1341 | { |
| 1342 | solAssert(m_stackState < ParsedAndImported, ""); |
| 1343 | StringMap newSources; |
| 1344 | try |
| 1345 | { |
| 1346 | for (auto const& node: _ast.nodes()) |
| 1347 | if (ImportDirective const* import = dynamic_cast<ImportDirective*>(node.get())) |
| 1348 | { |
| 1349 | std::string const& importPath = *import->annotation().absolutePath; |
| 1350 | |
| 1351 | if (m_sources.count(importPath) || newSources.count(importPath)) |
| 1352 | continue; |
| 1353 | |
| 1354 | ReadCallback::Result result{false, std::string("File not supplied initially.")}; |
| 1355 | if (m_readFile) |
| 1356 | result = m_readFile(ReadCallback::kindString(ReadCallback::Kind::ReadFile), importPath); |
| 1357 | |
| 1358 | if (result.success) |
| 1359 | newSources[importPath] = result.responseOrErrorMessage; |
| 1360 | else |
| 1361 | { |
| 1362 | m_errorReporter.parserError( |
| 1363 | 6275_error, |
| 1364 | import->location(), |
| 1365 | std::string("Source \"" + importPath + "\" not found: " + result.responseOrErrorMessage) |
| 1366 | ); |
| 1367 | continue; |
| 1368 | } |
| 1369 | } |
| 1370 | } |
| 1371 | catch (FatalError const&) |
| 1372 | { |
| 1373 | if (!m_errorReporter.hasErrors()) |
| 1374 | { |
| 1375 | std::cerr << "Unreported fatal error:" << std::endl; |
| 1376 | std::cerr << boost::current_exception_diagnostic_information() << std::endl; |
| 1377 | solAssert(false, "Unreported fatal error."); |
| 1378 | } |
| 1379 | } |
| 1380 | return newSources; |
| 1381 | } |
| 1382 | |
| 1383 | std::string CompilerStack::applyRemapping(std::string const& _path, std::string const& _context) |
| 1384 | { |