Move scopes into resolver.

This commit is contained in:
chriseth
2020-05-14 13:16:47 +02:00
parent f83ef2300b
commit e751a1c23d
6 changed files with 6 additions and 14 deletions
+1 -4
View File
@@ -37,16 +37,13 @@ namespace solidity::frontend
NameAndTypeResolver::NameAndTypeResolver(
GlobalContext& _globalContext,
langutil::EVMVersion _evmVersion,
map<ASTNode const*, shared_ptr<DeclarationContainer>>& _scopes,
ErrorReporter& _errorReporter
):
m_scopes(_scopes),
m_evmVersion(_evmVersion),
m_errorReporter(_errorReporter),
m_globalContext(_globalContext)
{
if (!m_scopes[nullptr])
m_scopes[nullptr] = make_shared<DeclarationContainer>();
m_scopes[nullptr] = make_shared<DeclarationContainer>();
for (Declaration const* declaration: _globalContext.declarations())
{
solAssert(m_scopes[nullptr]->registerDeclaration(*declaration), "Unable to register global declaration.");
+1 -2
View File
@@ -56,7 +56,6 @@ public:
NameAndTypeResolver(
GlobalContext& _globalContext,
langutil::EVMVersion _evmVersion,
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>>& _scopes,
langutil::ErrorReporter& _errorReporter
);
/// Registers all declarations found in the AST node, usually a source unit.
@@ -123,7 +122,7 @@ private:
/// where nullptr denotes the global scope. Note that structs are not scope since they do
/// not contain code.
/// Aliases (for example `import "x" as y;`) create multiple pointers to the same scope.
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>>& m_scopes;
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>> m_scopes;
langutil::EVMVersion m_evmVersion;
DeclarationContainer* m_currentScope = nullptr;
+2 -2
View File
@@ -214,7 +214,6 @@ void CompilerStack::reset(bool _keepSettings)
m_metadataHash = MetadataHash::IPFS;
}
m_globalContext.reset();
m_scopes.clear();
m_sourceOrder.clear();
m_contracts.clear();
m_errorReporter.clear();
@@ -314,7 +313,8 @@ bool CompilerStack::analyze()
noErrors = false;
m_globalContext = make_shared<GlobalContext>();
NameAndTypeResolver resolver(*m_globalContext, m_evmVersion, m_scopes, m_errorReporter);
// We need to keep the same resolver during the whole process.
NameAndTypeResolver resolver(*m_globalContext, m_evmVersion, m_errorReporter);
for (Source const* source: m_sourceOrder)
if (source->ast && !resolver.registerDeclarations(*source->ast))
return false;
-2
View File
@@ -447,8 +447,6 @@ private:
std::map<util::h256, std::string> m_smtlib2Responses;
std::shared_ptr<GlobalContext> m_globalContext;
std::vector<Source const*> m_sourceOrder;
/// This is updated during compilation.
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>> m_scopes;
std::map<std::string const, Contract> m_contracts;
langutil::ErrorList m_errorList;
langutil::ErrorReporter m_errorReporter;