diff options
author | chriseth <chris@ethereum.org> | 2017-05-03 20:36:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-03 20:36:32 +0800 |
commit | 68ef5810593e7c8092ed41d5f474dd43141624eb (patch) | |
tree | 36453acfef9495095dc47305d9b40c2cd3b63813 /libevmasm/ConstantOptimiser.h | |
parent | f0d539ae05739e35336cc9cc8f44bd9798a95c28 (diff) | |
parent | 34b28ed760e8ba9b86f661c819fe489fb8403235 (diff) | |
download | dexon-solidity-68ef5810593e7c8092ed41d5f474dd43141624eb.tar dexon-solidity-68ef5810593e7c8092ed41d5f474dd43141624eb.tar.gz dexon-solidity-68ef5810593e7c8092ed41d5f474dd43141624eb.tar.bz2 dexon-solidity-68ef5810593e7c8092ed41d5f474dd43141624eb.tar.lz dexon-solidity-68ef5810593e7c8092ed41d5f474dd43141624eb.tar.xz dexon-solidity-68ef5810593e7c8092ed41d5f474dd43141624eb.tar.zst dexon-solidity-68ef5810593e7c8092ed41d5f474dd43141624eb.zip |
Merge pull request #2219 from ethereum/develop
Release for version 0.4.11
Diffstat (limited to 'libevmasm/ConstantOptimiser.h')
-rw-r--r-- | libevmasm/ConstantOptimiser.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libevmasm/ConstantOptimiser.h b/libevmasm/ConstantOptimiser.h index 4f12c49f..85bdabac 100644 --- a/libevmasm/ConstantOptimiser.h +++ b/libevmasm/ConstantOptimiser.h @@ -21,10 +21,14 @@ #pragma once -#include <vector> +#include <libevmasm/Exceptions.h> + +#include <libdevcore/Assertions.h> #include <libdevcore/CommonData.h> #include <libdevcore/CommonIO.h> +#include <vector> + namespace dev { namespace eth @@ -130,6 +134,11 @@ public: ConstantOptimisationMethod(_params, _value) { m_routine = findRepresentation(m_value); + assertThrow( + checkRepresentation(m_value, m_routine), + OptimizerException, + "Invalid constant expression created." + ); } virtual bigint gasNeeded() override { return gasNeeded(m_routine); } @@ -141,6 +150,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, AssemblyItems const& _routine); bigint gasNeeded(AssemblyItems const& _routine); /// Counter for the complexity of optimization, will stop when it reaches zero. |