style fixes mostly

This commit is contained in:
LianaHus 2015-10-15 16:08:02 +02:00
parent cd6262998c
commit 68e126dc7d
4 changed files with 42 additions and 18 deletions

View File

@ -97,7 +97,9 @@ void CompilerStack::setSource(string const& _sourceCode)
bool CompilerStack::parse()
{
//reset
m_errors.clear();
m_parseSuccessful = false;
for (auto& sourcePair: m_sources)
{
@ -114,7 +116,9 @@ bool CompilerStack::parse()
bool success = true;
NameAndTypeResolver resolver(m_globalContext->declarations(), m_errors);
for (Source const* source: m_sourceOrder)
success = success && resolver.registerDeclarations(*source->ast);
if (!resolver.registerDeclarations(*source->ast))
return false;
for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))

View File

@ -60,7 +60,7 @@ public:
{
for (auto e: _list)
{
if(e->type() == _type)
if (e->type() == _type)
return e.get();
}
return nullptr;
@ -69,7 +69,7 @@ public:
{
for (auto e: _list)
{
if(e->type() != Type::Warning)
if (e->type() != Type::Warning)
return false;
}
return true;

View File

@ -296,17 +296,25 @@ vector<_T const*> NameAndTypeResolver::cThreeMerge(list<list<_T const*>>& _toMer
void NameAndTypeResolver::reportDeclarationError(
SourceLocation _sourceLoction,
string const& _description,
SourceLocation _secondarySourceLocation = SourceLocation(),
string const& _secondaryDescription = ""
SourceLocation _secondarySourceLocation,
string const& _secondaryDescription
)
{
auto err = make_shared<Error>(Error::Type::DeclarationError); // todo remove Error?
*err <<
errinfo_sourceLocation(_sourceLoction) <<
errinfo_comment(_description) <<
errinfo_secondarySourceLocation(
SecondarySourceLocation().append(_secondaryDescription, _secondarySourceLocation)
);
errinfo_sourceLocation(_sourceLoction) <<
errinfo_comment(_description) <<
errinfo_secondarySourceLocation(
SecondarySourceLocation().append(_secondaryDescription, _secondarySourceLocation)
);
m_errors.push_back(err);
}
void NameAndTypeResolver::reportDeclarationError(SourceLocation _sourceLoction, string const& _description)
{
auto err = make_shared<Error>(Error::Type::DeclarationError); // todo remove Error?
*err << errinfo_sourceLocation(_sourceLoction) << errinfo_comment(_description);
m_errors.push_back(err);
}
@ -331,7 +339,6 @@ void NameAndTypeResolver::reportFatalTypeError(Error _e)
BOOST_THROW_EXCEPTION(FatalError());
}
DeclarationRegistrationHelper::DeclarationRegistrationHelper(
map<ASTNode const*, DeclarationContainer>& _scopes,
ASTNode& _astRoot,
@ -506,17 +513,25 @@ string DeclarationRegistrationHelper::currentCanonicalName() const
void DeclarationRegistrationHelper::declarationError(
SourceLocation _sourceLoction,
string const& _description,
SourceLocation _secondarySourceLocation = SourceLocation(),
string const& _secondaryDescription = ""
SourceLocation _secondarySourceLocation,
string const& _secondaryDescription
)
{
auto err = make_shared<Error>(Error::Type::DeclarationError);
*err <<
errinfo_sourceLocation(_sourceLoction) <<
errinfo_comment(_description) <<
errinfo_secondarySourceLocation(
SecondarySourceLocation().append(_secondaryDescription, _secondarySourceLocation)
);
errinfo_sourceLocation(_sourceLoction) <<
errinfo_comment(_description) <<
errinfo_secondarySourceLocation(
SecondarySourceLocation().append(_secondaryDescription, _secondarySourceLocation)
);
m_errors.push_back(err);
}
void DeclarationRegistrationHelper::declarationError(SourceLocation _sourceLoction, string const& _description)
{
auto err = make_shared<Error>(Error::Type::DeclarationError);
*err << errinfo_sourceLocation(_sourceLoction) << errinfo_comment(_description);
m_errors.push_back(err);
}

View File

@ -100,6 +100,8 @@ private:
SourceLocation _secondarySourceLocation,
std::string const& _secondaryDescription
);
// creates the Declaration error and adds it in the errors list
void reportDeclarationError(SourceLocation _sourceLoction, std::string const& _description);
// creates the Declaration error and adds it in the errors list and throws FatalError
void reportFatalDeclarationError(SourceLocation _sourceLoction, std::string _description);
@ -151,6 +153,9 @@ private:
SourceLocation _secondarySourceLocation,
std::string const& _secondaryDescription
);
// creates the Declaration error and adds it in the errors list
void declarationError(SourceLocation _sourceLoction, std::string const& _description);
// creates the Declaration error and adds it in the errors list and throws FatalError
void fatalDeclarationError(SourceLocation _sourceLoction, std::string const& _description);