aboutsummaryrefslogtreecommitdiffstats
path: root/libevmasm/ConstantOptimiser.h
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-04-03 20:40:39 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-04-27 21:06:28 +0800
commit54210ea89f1f115ee9dba9008ff5ea8ddb74c839 (patch)
tree6e8f60f6d35886abc409e107a4f0907ca841d45b /libevmasm/ConstantOptimiser.h
parent2c1fb46bc341d9e44074af23cd4eadd3a9f732c5 (diff)
downloaddexon-solidity-54210ea89f1f115ee9dba9008ff5ea8ddb74c839.tar.gz
dexon-solidity-54210ea89f1f115ee9dba9008ff5ea8ddb74c839.tar.zst
dexon-solidity-54210ea89f1f115ee9dba9008ff5ea8ddb74c839.zip
Add recomputation check for number representation.
Diffstat (limited to 'libevmasm/ConstantOptimiser.h')
-rw-r--r--libevmasm/ConstantOptimiser.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/libevmasm/ConstantOptimiser.h b/libevmasm/ConstantOptimiser.h
index 4f12c49f..8a37b3cb 100644
--- a/libevmasm/ConstantOptimiser.h
+++ b/libevmasm/ConstantOptimiser.h
@@ -21,10 +21,13 @@
#pragma once
-#include <vector>
+#include <libevmasm/Exceptions.h>
+
#include <libdevcore/CommonData.h>
#include <libdevcore/CommonIO.h>
+#include <vector>
+
namespace dev
{
namespace eth
@@ -130,6 +133,8 @@ public:
ConstantOptimisationMethod(_params, _value)
{
m_routine = findRepresentation(m_value);
+ if (!checkRepresentation(m_value))
+ BOOST_THROW_EXCEPTION(AssemblyException());
}
virtual bigint gasNeeded() override { return gasNeeded(m_routine); }
@@ -141,6 +146,8 @@ public:
protected:
/// Tries to recursively find a way to compute @a _value.
AssemblyItems findRepresentation(u256 const& _value);
+ /// Recomputes the value from the calculated representation and checks for correctness.
+ bool checkRepresentation(u256 const& _value);
bigint gasNeeded(AssemblyItems const& _routine);
/// Counter for the complexity of optimization, will stop when it reaches zero.