Source units are independent scopes.

This commit is contained in:
chriseth
2015-12-09 19:09:24 +01:00
parent e510e7e792
commit 7cb7818cea
9 changed files with 204 additions and 55 deletions
+6
View File
@@ -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()))