MCPcopy Create free account
hub / github.com/argotorg/solidity / loadMissingSources

Method loadMissingSources

libsolidity/interface/CompilerStack.cpp:1340–1381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1338}
1339
1340StringMap 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
1383std::string CompilerStack::applyRemapping(std::string const& _path, std::string const& _context)
1384{

Callers

nothing calls this directly

Calls 6

nodesMethod · 0.80
getMethod · 0.45
countMethod · 0.45
parserErrorMethod · 0.45
locationMethod · 0.45
hasErrorsMethod · 0.45

Tested by

no test coverage detected