mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Resolve stdlib imports on demand
This commit is contained in:
parent
f8b52f8d4d
commit
aceb9dc5d1
@ -587,7 +587,7 @@ bool DeclarationRegistrationHelper::visit(ImportDirective& _import)
|
||||
solAssert(!!importee, "");
|
||||
if (!m_scopes[importee])
|
||||
m_scopes[importee] = make_shared<DeclarationContainer>(importee, nullptr, m_scopes[nullptr].get());
|
||||
// TODO here, m_selfNode inside the contanier does not point to the key of m_scopes (_import) - is that a problem?
|
||||
// TODO here, m_selfNode inside the container does not point to the key of m_scopes (_import) - is that a problem?
|
||||
m_scopes[&_import] = m_scopes[importee];
|
||||
ASTVisitor::visit(_import);
|
||||
return false; // Do not recurse into child nodes (Identifier for symbolAliases)
|
||||
|
@ -77,7 +77,7 @@
|
||||
#include <libsolutil/Algorithms.h>
|
||||
#include <libsolutil/FunctionSelector.h>
|
||||
|
||||
#include "solstdlib.h"
|
||||
#include <solstdlib.h>
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
@ -352,9 +352,6 @@ bool CompilerStack::parse()
|
||||
|
||||
Parser parser{m_errorReporter, m_evmVersion, m_parserErrorRecovery};
|
||||
|
||||
for (auto [name, content]: solidity::solstdlib::sources)
|
||||
m_sources[name].charStream = make_unique<CharStream>(content, name);
|
||||
|
||||
vector<string> sourcesToParse;
|
||||
for (auto const& s: m_sources)
|
||||
sourcesToParse.push_back(s.first);
|
||||
@ -374,6 +371,14 @@ bool CompilerStack::parse()
|
||||
{
|
||||
solAssert(!import->path().empty(), "Import path cannot be empty.");
|
||||
|
||||
auto it = solidity::solstdlib::sources.find(import->path());
|
||||
if (it != solidity::solstdlib::sources.end())
|
||||
{
|
||||
auto [name, content] = *it;
|
||||
m_sources[name].charStream = make_unique<CharStream>(content, name);
|
||||
sourcesToParse.push_back(name);
|
||||
}
|
||||
|
||||
// The current value of `path` is the absolute path as seen from this source file.
|
||||
// We first have to apply remappings before we can store the actual absolute path
|
||||
// as seen globally.
|
||||
@ -1166,7 +1171,6 @@ StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast)
|
||||
if (ImportDirective const* import = dynamic_cast<ImportDirective*>(node.get()))
|
||||
{
|
||||
string const& importPath = *import->annotation().absolutePath;
|
||||
|
||||
if (m_sources.count(importPath) || newSources.count(importPath))
|
||||
continue;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user