mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Source units are independent scopes.
This commit is contained in:
@@ -103,12 +103,14 @@ bool CompilerStack::parse()
|
||||
m_errors.clear();
|
||||
m_parseSuccessful = false;
|
||||
|
||||
map<string, SourceUnit const*> sourceUnitsByName;
|
||||
for (auto& sourcePair: m_sources)
|
||||
{
|
||||
sourcePair.second.scanner->reset();
|
||||
sourcePair.second.ast = Parser(m_errors).parse(sourcePair.second.scanner);
|
||||
if (!sourcePair.second.ast)
|
||||
solAssert(!Error::containsOnlyWarnings(m_errors), "Parser returned null but did not report error.");
|
||||
sourceUnitsByName[sourcePair.first] = sourcePair.second.ast.get();
|
||||
}
|
||||
if (!Error::containsOnlyWarnings(m_errors))
|
||||
// errors while parsing. sould stop before type checking
|
||||
@@ -128,6 +130,10 @@ bool CompilerStack::parse()
|
||||
if (!resolver.registerDeclarations(*source->ast))
|
||||
return false;
|
||||
|
||||
for (Source const* source: m_sourceOrder)
|
||||
if (!resolver.performImports(*source->ast, sourceUnitsByName))
|
||||
return false;
|
||||
|
||||
for (Source const* source: m_sourceOrder)
|
||||
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
|
||||
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
||||
|
||||
Reference in New Issue
Block a user