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() bool CompilerStack::parse()
{ {
//reset
m_errors.clear(); m_errors.clear();
m_parseSuccessful = false;
for (auto& sourcePair: m_sources) for (auto& sourcePair: m_sources)
{ {
@ -114,7 +116,9 @@ bool CompilerStack::parse()
bool success = true; bool success = true;
NameAndTypeResolver resolver(m_globalContext->declarations(), m_errors); NameAndTypeResolver resolver(m_globalContext->declarations(), m_errors);
for (Source const* source: m_sourceOrder) 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 (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()))

View File

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

View File

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

View File

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