mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
fixed test framework
This commit is contained in:
parent
7eb162c0df
commit
63060fc1f0
@ -84,9 +84,6 @@ bool NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract)
|
|||||||
importInheritedScope(*base);
|
importInheritedScope(*base);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (ASTPointer<StructDefinition> const& structDef: _contract.definedStructs())
|
for (ASTPointer<StructDefinition> const& structDef: _contract.definedStructs())
|
||||||
if (!resolver.resolve(*structDef))
|
if (!resolver.resolve(*structDef))
|
||||||
success = false;
|
success = false;
|
||||||
@ -100,8 +97,6 @@ bool NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract)
|
|||||||
if (!resolver.resolve(*event))
|
if (!resolver.resolve(*event))
|
||||||
success = false;
|
success = false;
|
||||||
// these can contain code, only resolve parameters for now
|
// these can contain code, only resolve parameters for now
|
||||||
if (!success)
|
|
||||||
return false;
|
|
||||||
for (ASTPointer<ModifierDefinition> const& modifier: _contract.functionModifiers())
|
for (ASTPointer<ModifierDefinition> const& modifier: _contract.functionModifiers())
|
||||||
{
|
{
|
||||||
m_currentScope = &m_scopes[modifier.get()];
|
m_currentScope = &m_scopes[modifier.get()];
|
||||||
@ -110,8 +105,6 @@ bool NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract)
|
|||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success)
|
|
||||||
return false;
|
|
||||||
for (ASTPointer<FunctionDefinition> const& function: _contract.definedFunctions())
|
for (ASTPointer<FunctionDefinition> const& function: _contract.definedFunctions())
|
||||||
{
|
{
|
||||||
m_currentScope = &m_scopes[function.get()];
|
m_currentScope = &m_scopes[function.get()];
|
||||||
@ -138,8 +131,6 @@ bool NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract)
|
|||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success)
|
|
||||||
return false;
|
|
||||||
for (ASTPointer<FunctionDefinition> const& function: _contract.definedFunctions())
|
for (ASTPointer<FunctionDefinition> const& function: _contract.definedFunctions())
|
||||||
{
|
{
|
||||||
m_currentScope = &m_scopes[function.get()];
|
m_currentScope = &m_scopes[function.get()];
|
||||||
|
@ -59,7 +59,14 @@ public:
|
|||||||
/// @returns true if no errors during resolving
|
/// @returns true if no errors during resolving
|
||||||
bool resolve(ASTNode& _root)
|
bool resolve(ASTNode& _root)
|
||||||
{
|
{
|
||||||
_root.accept(*this);
|
try
|
||||||
|
{
|
||||||
|
_root.accept(*this);
|
||||||
|
}
|
||||||
|
catch (FatalError const& e)
|
||||||
|
{
|
||||||
|
solAssert(m_errorOccurred, "");
|
||||||
|
}
|
||||||
return !m_errorOccurred;
|
return !m_errorOccurred;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,33 +62,36 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false)
|
|||||||
solAssert(Error::containsOnlyWarnings(errors), "");
|
solAssert(Error::containsOnlyWarnings(errors), "");
|
||||||
resolver.registerDeclarations(*sourceUnit);
|
resolver.registerDeclarations(*sourceUnit);
|
||||||
|
|
||||||
|
bool success = true;
|
||||||
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);
|
globalContext->setCurrentContract(*contract);
|
||||||
resolver.updateDeclaration(*globalContext->currentThis());
|
resolver.updateDeclaration(*globalContext->currentThis());
|
||||||
resolver.updateDeclaration(*globalContext->currentSuper());
|
resolver.updateDeclaration(*globalContext->currentSuper());
|
||||||
resolver.resolveNamesAndTypes(*contract);
|
if (! resolver.resolveNamesAndTypes(*contract))
|
||||||
|
success = false;
|
||||||
}
|
}
|
||||||
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
|
if (success)
|
||||||
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
|
||||||
{
|
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
||||||
globalContext->setCurrentContract(*contract);
|
|
||||||
resolver.updateDeclaration(*globalContext->currentThis());
|
|
||||||
|
|
||||||
TypeChecker typeChecker(errors);
|
|
||||||
bool success = typeChecker.checkTypeRequirements(*contract);
|
|
||||||
BOOST_CHECK(success || !errors.empty());
|
|
||||||
|
|
||||||
for (auto const& currentError: errors)
|
|
||||||
{
|
{
|
||||||
if (
|
globalContext->setCurrentContract(*contract);
|
||||||
(_reportWarnings && currentError->type() == Error::Type::Warning) ||
|
resolver.updateDeclaration(*globalContext->currentThis());
|
||||||
(!_reportWarnings && currentError->type() != Error::Type::Warning)
|
|
||||||
)
|
TypeChecker typeChecker(errors);
|
||||||
return make_pair(sourceUnit, std::make_shared<Error::Type const>(currentError->type()));
|
bool success = typeChecker.checkTypeRequirements(*contract);
|
||||||
|
BOOST_CHECK(success || !errors.empty());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
for (auto const& currentError: errors)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
(_reportWarnings && currentError->type() == Error::Type::Warning) ||
|
||||||
|
(!_reportWarnings && currentError->type() != Error::Type::Warning)
|
||||||
|
)
|
||||||
|
return make_pair(sourceUnit, std::make_shared<Error::Type const>(currentError->type()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(Error const& _e)
|
catch(Error const& _e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user