diff options
author | LianaHus <liana@ethdev.com> | 2015-10-15 22:08:02 +0800 |
---|---|---|
committer | LianaHus <liana@ethdev.com> | 2015-10-15 22:08:02 +0800 |
commit | 68e126dc7d85854aa1458934122a725e99eb36e0 (patch) | |
tree | 72e84f78ad5ef7d3617bb0860468c648b469eba7 | |
parent | cd6262998ccf3c712bb2af1981eeb943ccaf8094 (diff) | |
download | dexon-solidity-68e126dc7d85854aa1458934122a725e99eb36e0.tar dexon-solidity-68e126dc7d85854aa1458934122a725e99eb36e0.tar.gz dexon-solidity-68e126dc7d85854aa1458934122a725e99eb36e0.tar.bz2 dexon-solidity-68e126dc7d85854aa1458934122a725e99eb36e0.tar.lz dexon-solidity-68e126dc7d85854aa1458934122a725e99eb36e0.tar.xz dexon-solidity-68e126dc7d85854aa1458934122a725e99eb36e0.tar.zst dexon-solidity-68e126dc7d85854aa1458934122a725e99eb36e0.zip |
style fixes mostly
-rw-r--r-- | libsolidity/CompilerStack.cpp | 6 | ||||
-rw-r--r-- | libsolidity/Exceptions.h | 4 | ||||
-rw-r--r-- | libsolidity/NameAndTypeResolver.cpp | 45 | ||||
-rw-r--r-- | 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<ASTNode> const& node: source->ast->nodes()) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(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<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); } 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); |