From 3ec0bb5bfa986bb38c9a3d7a5a2dc43f3a3a9c15 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 21 Nov 2016 22:20:13 +0000 Subject: LLL: parseLLL to return empty string on failure --- liblll/Compiler.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'liblll') diff --git a/liblll/Compiler.cpp b/liblll/Compiler.cpp index 4008022f..0cec7bc8 100644 --- a/liblll/Compiler.cpp +++ b/liblll/Compiler.cpp @@ -99,14 +99,15 @@ std::string dev::eth::compileLLLToAsm(std::string const& _src, bool _opt, std::v string dev::eth::parseLLL(string const& _src) { - sp::utree o; try { + sp::utree o; parseTreeLLL(_src, o); + ostringstream ret; + debugOutAST(ret, o); + killBigints(o); + return ret.str(); } catch (...) {} - ostringstream ret; - debugOutAST(ret, o); - killBigints(o); - return ret.str(); + return string(); } -- cgit From d82eac3fed6547ddcaac8ecccb15c7f7eaa74d16 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 29 Nov 2016 22:04:51 +0000 Subject: LLL: parseLLL to be less greedy catching exceptions --- liblll/Compiler.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'liblll') diff --git a/liblll/Compiler.cpp b/liblll/Compiler.cpp index 0cec7bc8..73a82a35 100644 --- a/liblll/Compiler.cpp +++ b/liblll/Compiler.cpp @@ -99,15 +99,28 @@ std::string dev::eth::compileLLLToAsm(std::string const& _src, bool _opt, std::v string dev::eth::parseLLL(string const& _src) { + bool failed = false; + sp::utree o; + try { - sp::utree o; parseTreeLLL(_src, o); - ostringstream ret; - debugOutAST(ret, o); - killBigints(o); + } + catch (...) + { + failed = true; + } + + ostringstream ret; + debugOutAST(ret, o); + killBigints(o); + + if (failed) + { + return string(); + } + else + { return ret.str(); } - catch (...) {} - return string(); } -- cgit From 53d4433484c33b32d4d1063330633a308c0e48dd Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 30 Nov 2016 15:06:13 +0000 Subject: LLL: simplify error handling in parseLLL --- liblll/Compiler.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'liblll') diff --git a/liblll/Compiler.cpp b/liblll/Compiler.cpp index 73a82a35..cd909f34 100644 --- a/liblll/Compiler.cpp +++ b/liblll/Compiler.cpp @@ -99,7 +99,6 @@ std::string dev::eth::compileLLLToAsm(std::string const& _src, bool _opt, std::v string dev::eth::parseLLL(string const& _src) { - bool failed = false; sp::utree o; try @@ -108,19 +107,12 @@ string dev::eth::parseLLL(string const& _src) } catch (...) { - failed = true; + killBigints(o); + return string(); } ostringstream ret; debugOutAST(ret, o); killBigints(o); - - if (failed) - { - return string(); - } - else - { - return ret.str(); - } + return ret.str(); } -- cgit