From 7cb7818ceaf8f2e50cdd66b33a4e0d17c2a0e879 Mon Sep 17 00:00:00 2001 From: chriseth Date: Sat, 5 Dec 2015 03:09:47 +0100 Subject: Source units are independent scopes. --- libsolidity/interface/CompilerStack.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libsolidity/interface') diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 18eec0a2..38fe5956 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -103,12 +103,14 @@ bool CompilerStack::parse() m_errors.clear(); m_parseSuccessful = false; + map 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 const& node: source->ast->nodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) -- cgit