From 68e126dc7d85854aa1458934122a725e99eb36e0 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Thu, 15 Oct 2015 16:08:02 +0200 Subject: style fixes mostly --- libsolidity/CompilerStack.cpp | 6 ++++- libsolidity/Exceptions.h | 4 ++-- libsolidity/NameAndTypeResolver.cpp | 45 ++++++++++++++++++++++++------------- libsolidity/NameAndTypeResolver.h | 5 +++++ 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index cfd01310..1165d6f6 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -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 const& node: source->ast->nodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) diff --git a/libsolidity/Exceptions.h b/libsolidity/Exceptions.h index 59d69a27..cda6b97e 100644 --- a/libsolidity/Exceptions.h +++ b/libsolidity/Exceptions.h @@ -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; diff --git a/libsolidity/NameAndTypeResolver.cpp b/libsolidity/NameAndTypeResolver.cpp index dc82531f..fc83403f 100644 --- a/libsolidity/NameAndTypeResolver.cpp +++ b/libsolidity/NameAndTypeResolver.cpp @@ -296,17 +296,25 @@ vector<_T const*> NameAndTypeResolver::cThreeMerge(list>& _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::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::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& _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::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::Type::DeclarationError); + *err << errinfo_sourceLocation(_sourceLoction) << errinfo_comment(_description); m_errors.push_back(err); } diff --git a/libsolidity/NameAndTypeResolver.h b/libsolidity/NameAndTypeResolver.h index 9587fcfe..6a196b47 100644 --- a/libsolidity/NameAndTypeResolver.h +++ b/libsolidity/NameAndTypeResolver.h @@ -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); -- cgit v1.2.3