diff options
author | chriseth <c@ethdev.com> | 2015-09-22 01:43:56 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-09-22 02:03:53 +0800 |
commit | 42c0009205852abc2f2d7415a9e5faaf6e5b2d56 (patch) | |
tree | d88a500931a153eaa5a10b3fd883aa27652813c4 /libsolidity/CompilerStack.cpp | |
parent | 39d1e2bc06a5c39180681c78e8f6618f25da2bce (diff) | |
download | dexon-solidity-42c0009205852abc2f2d7415a9e5faaf6e5b2d56.tar.gz dexon-solidity-42c0009205852abc2f2d7415a9e5faaf6e5b2d56.tar.zst dexon-solidity-42c0009205852abc2f2d7415a9e5faaf6e5b2d56.zip |
Error formatting.
Diffstat (limited to 'libsolidity/CompilerStack.cpp')
-rw-r--r-- | libsolidity/CompilerStack.cpp | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index b8139187..e6b87264 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -77,6 +77,7 @@ void CompilerStack::reset(bool _keepSources, bool _addStandardSources) m_globalContext.reset(); m_sourceOrder.clear(); m_contracts.clear(); + m_errors.clear(); } bool CompilerStack::addSource(string const& _name, string const& _content, bool _isLibrary) @@ -94,8 +95,10 @@ void CompilerStack::setSource(string const& _sourceCode) addSource("", _sourceCode); } -void CompilerStack::parse() +bool CompilerStack::parse() { + m_errors.clear(); + for (auto& sourcePair: m_sources) { sourcePair.second.scanner->reset(); @@ -117,6 +120,7 @@ void CompilerStack::parse() resolver.resolveNamesAndTypes(*contract); m_contracts[contract->name()].contract = contract; } + InterfaceHandler interfaceHandler; for (Source const* source: m_sourceOrder) for (ASTPointer<ASTNode> const& node: source->ast->nodes()) @@ -127,20 +131,19 @@ void CompilerStack::parse() TypeChecker typeChecker; bool typesFine = typeChecker.checkTypeRequirements(*contract); if (!typesFine) - BOOST_THROW_EXCEPTION(*typeChecker.errors().front()); - //@todo extract warnings and errors - // store whether we had an error + m_errors += typeChecker.errors(); contract->setDevDocumentation(interfaceHandler.devDocumentation(*contract)); contract->setUserDocumentation(interfaceHandler.userDocumentation(*contract)); m_contracts[contract->name()].contract = contract; } - m_parseSuccessful = true; + m_parseSuccessful = m_errors.empty(); + return m_parseSuccessful; } -void CompilerStack::parse(string const& _sourceCode) +bool CompilerStack::parse(string const& _sourceCode) { setSource(_sourceCode); - parse(); + return parse(); } vector<string> CompilerStack::contractNames() const @@ -154,12 +157,11 @@ vector<string> CompilerStack::contractNames() const } -void CompilerStack::compile(bool _optimize, unsigned _runs) +bool CompilerStack::compile(bool _optimize, unsigned _runs) { if (!m_parseSuccessful) - parse(); - - //@todo do not compile or error (also in other places) + if (!parse()) + return false; map<ContractDefinition const*, eth::Assembly const*> compiledContracts; for (Source const* source: m_sourceOrder) @@ -180,13 +182,12 @@ void CompilerStack::compile(bool _optimize, unsigned _runs) cloneCompiler.compileClone(*contract, compiledContracts); compiledContract.cloneObject = cloneCompiler.assembledObject(); } + return true; } -eth::LinkerObject const& CompilerStack::compile(string const& _sourceCode, bool _optimize) +bool CompilerStack::compile(string const& _sourceCode, bool _optimize) { - parse(_sourceCode); - compile(_optimize); - return object(); + return parse(_sourceCode) && compile(_optimize); } void CompilerStack::link(const std::map<string, h160>& _libraries) @@ -325,12 +326,6 @@ size_t CompilerStack::functionEntryPoint( return 0; } -eth::LinkerObject CompilerStack::staticCompile(std::string const& _sourceCode, bool _optimize) -{ - CompilerStack stack; - return stack.compile(_sourceCode, _optimize); -} - tuple<int, int, int, int> CompilerStack::positionFromSourceLocation(SourceLocation const& _sourceLocation) const { int startLine; |