mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #2819 from ethereum/compilerstack-typecheck
Simplify typechecking loop in compilerstack
This commit is contained in:
commit
372279ceb2
@ -188,6 +188,9 @@ bool CompilerStack::analyze()
|
|||||||
if (!resolver.updateDeclaration(*m_globalContext->currentSuper())) return false;
|
if (!resolver.updateDeclaration(*m_globalContext->currentSuper())) return false;
|
||||||
if (!resolver.resolveNamesAndTypes(*contract)) return false;
|
if (!resolver.resolveNamesAndTypes(*contract)) return false;
|
||||||
|
|
||||||
|
contract->setDevDocumentation(Natspec::devDocumentation(*contract));
|
||||||
|
contract->setUserDocumentation(Natspec::userDocumentation(*contract));
|
||||||
|
|
||||||
// Note that we now reference contracts by their fully qualified names, and
|
// Note that we now reference contracts by their fully qualified names, and
|
||||||
// thus contracts can only conflict if declared in the same source file. This
|
// thus contracts can only conflict if declared in the same source file. This
|
||||||
// already causes a double-declaration error elsewhere, so we do not report
|
// already causes a double-declaration error elsewhere, so we do not report
|
||||||
@ -197,30 +200,13 @@ bool CompilerStack::analyze()
|
|||||||
m_contracts[contract->fullyQualifiedName()].contract = contract;
|
m_contracts[contract->fullyQualifiedName()].contract = contract;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TypeChecker typeChecker(m_errorReporter);
|
||||||
for (Source const* source: m_sourceOrder)
|
for (Source const* source: m_sourceOrder)
|
||||||
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
|
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
|
||||||
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
||||||
{
|
if (!typeChecker.checkTypeRequirements(*contract))
|
||||||
m_globalContext->setCurrentContract(*contract);
|
|
||||||
resolver.updateDeclaration(*m_globalContext->currentThis());
|
|
||||||
TypeChecker typeChecker(m_errorReporter);
|
|
||||||
if (typeChecker.checkTypeRequirements(*contract))
|
|
||||||
{
|
|
||||||
contract->setDevDocumentation(Natspec::devDocumentation(*contract));
|
|
||||||
contract->setUserDocumentation(Natspec::userDocumentation(*contract));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
noErrors = false;
|
noErrors = false;
|
||||||
|
|
||||||
// Note that we now reference contracts by their fully qualified names, and
|
|
||||||
// thus contracts can only conflict if declared in the same source file. This
|
|
||||||
// already causes a double-declaration error elsewhere, so we do not report
|
|
||||||
// an error here and instead silently drop any additional contracts we find.
|
|
||||||
|
|
||||||
if (m_contracts.find(contract->fullyQualifiedName()) == m_contracts.end())
|
|
||||||
m_contracts[contract->fullyQualifiedName()].contract = contract;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (noErrors)
|
if (noErrors)
|
||||||
{
|
{
|
||||||
PostTypeChecker postTypeChecker(m_errorReporter);
|
PostTypeChecker postTypeChecker(m_errorReporter);
|
||||||
|
@ -87,16 +87,15 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false,
|
|||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
if (success)
|
if (success)
|
||||||
|
{
|
||||||
|
TypeChecker typeChecker(errorReporter);
|
||||||
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
|
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
|
||||||
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
||||||
{
|
{
|
||||||
globalContext->setCurrentContract(*contract);
|
|
||||||
resolver.updateDeclaration(*globalContext->currentThis());
|
|
||||||
|
|
||||||
TypeChecker typeChecker(errorReporter);
|
|
||||||
bool success = typeChecker.checkTypeRequirements(*contract);
|
bool success = typeChecker.checkTypeRequirements(*contract);
|
||||||
BOOST_CHECK(success || !errorReporter.errors().empty());
|
BOOST_CHECK(success || !errorReporter.errors().empty());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (success)
|
if (success)
|
||||||
if (!PostTypeChecker(errorReporter).check(*sourceUnit))
|
if (!PostTypeChecker(errorReporter).check(*sourceUnit))
|
||||||
success = false;
|
success = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user