aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-10-17 20:16:41 +0800
committerGitHub <noreply@github.com>2016-10-17 20:16:41 +0800
commit07d32937fd1aa0860611ce1307f08439317de449 (patch)
treef2a23ddceb8298eaed8e213c92f3bae91f6322c1
parentcc2a6867a7986b04c3f8013f508df77eab738d19 (diff)
parent8aa50a004fb320b927b96576f085cfbe5f845da6 (diff)
downloaddexon-solidity-07d32937fd1aa0860611ce1307f08439317de449.tar.gz
dexon-solidity-07d32937fd1aa0860611ce1307f08439317de449.tar.zst
dexon-solidity-07d32937fd1aa0860611ce1307f08439317de449.zip
Merge pull request #1229 from ethereum/lll-error-reporting
LLL: better error reporting
-rw-r--r--liblll/CodeFragment.cpp17
-rw-r--r--liblll/Compiler.cpp30
-rw-r--r--liblll/Exceptions.h1
-rw-r--r--liblll/Parser.cpp5
-rw-r--r--liblll/Parser.h1
5 files changed, 38 insertions, 16 deletions
diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp
index e9f86ba0..9dcac845 100644
--- a/liblll/CodeFragment.cpp
+++ b/liblll/CodeFragment.cpp
@@ -52,17 +52,18 @@ void CodeFragment::finalise(CompilerState const& _cs)
CodeFragment::CodeFragment(sp::utree const& _t, CompilerState& _s, bool _allowASM)
{
-/* cdebug << "CodeFragment. Locals:";
+/*
+ std::cout << "CodeFragment. Locals:";
for (auto const& i: _s.defs)
- cdebug << i.first << ":" << toHex(i.second.m_code);
- cdebug << "Args:";
+ std::cout << i.first << ":" << i.second.m_asm.out();
+ std::cout << "Args:";
for (auto const& i: _s.args)
- cdebug << i.first << ":" << toHex(i.second.m_code);
- cdebug << "Outers:";
+ std::cout << i.first << ":" << i.second.m_asm.out();
+ std::cout << "Outers:";
for (auto const& i: _s.outers)
- cdebug << i.first << ":" << toHex(i.second.m_code);
- debugOutAST(cout, _t);
- cout << endl << flush;
+ std::cout << i.first << ":" << i.second.m_asm.out();
+ debugOutAST(std::cout, _t);
+ std::cout << endl << flush;
*/
switch (_t.which())
{
diff --git a/liblll/Compiler.cpp b/liblll/Compiler.cpp
index f1538789..68499106 100644
--- a/liblll/Compiler.cpp
+++ b/liblll/Compiler.cpp
@@ -45,13 +45,21 @@ bytes dev::eth::compileLLL(string const& _src, bool _opt, vector<string>* _error
if (_errors)
{
_errors->push_back("Parse error.");
- _errors->push_back(diagnostic_information(_e));
+ _errors->push_back(boost::diagnostic_information(_e));
}
}
- catch (std::exception)
+ catch (std::exception const& _e)
{
if (_errors)
- _errors->push_back("Parse error.");
+ {
+ _errors->push_back("Parse exception.");
+ _errors->push_back(boost::diagnostic_information(_e));
+ }
+ }
+ catch (...)
+ {
+ if (_errors)
+ _errors->push_back("Internal parse exception.");
}
return bytes();
}
@@ -70,12 +78,22 @@ std::string dev::eth::compileLLLToAsm(std::string const& _src, bool _opt, std::v
catch (Exception const& _e)
{
if (_errors)
- _errors->push_back(diagnostic_information(_e));
+ {
+ _errors->push_back("Parse error.");
+ _errors->push_back(boost::diagnostic_information(_e));
+ }
+ }
+ catch (std::exception const& _e)
+ {
+ if (_errors) {
+ _errors->push_back("Parse exception.");
+ _errors->push_back(boost::diagnostic_information(_e));
+ }
}
- catch (std::exception)
+ catch (...)
{
if (_errors)
- _errors->push_back("Parse error.");
+ _errors->push_back("Internal parse exception.");
}
return string();
}
diff --git a/liblll/Exceptions.h b/liblll/Exceptions.h
index 1e9671b3..aa4bf4e8 100644
--- a/liblll/Exceptions.h
+++ b/liblll/Exceptions.h
@@ -39,6 +39,7 @@ class InvalidName: public CompilerException {};
class InvalidMacroArgs: public CompilerException {};
class InvalidLiteral: public CompilerException {};
class BareSymbol: public CompilerException {};
+class ParserException: public CompilerException {};
}
}
diff --git a/liblll/Parser.cpp b/liblll/Parser.cpp
index aa4a4de2..daced13c 100644
--- a/liblll/Parser.cpp
+++ b/liblll/Parser.cpp
@@ -143,7 +143,8 @@ void dev::eth::parseTreeLLL(string const& _s, sp::utree& o_out)
auto ret = s.cbegin();
qi::phrase_parse(ret, s.cend(), element, space, qi::skip_flag::dont_postskip, o_out);
for (auto i = ret; i != s.cend(); ++i)
- if (!isspace(*i))
- BOOST_THROW_EXCEPTION(std::exception());
+ if (!isspace(*i)) {
+ BOOST_THROW_EXCEPTION(ParserException() << errinfo_comment("Non-whitespace left in parser"));
+ }
}
diff --git a/liblll/Parser.h b/liblll/Parser.h
index b21989f0..e4542888 100644
--- a/liblll/Parser.h
+++ b/liblll/Parser.h
@@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include <libdevcore/Common.h>
+#include "Exceptions.h"
namespace boost { namespace spirit { class utree; } }
namespace sp = boost::spirit;