Take only Assembly instance as an input to ConstantOptimiser

This commit is contained in:
Alex Beregszaszi
2019-01-31 16:02:29 +00:00
parent e83e9a81e5
commit ae1cd252b0
5 changed files with 11 additions and 9 deletions
+1 -2
View File
@@ -496,8 +496,7 @@ map<u256, u256> Assembly::optimiseInternal(
_settings.isCreation,
_settings.isCreation ? 1 : _settings.expectedExecutionsPerDeployment,
_settings.evmVersion,
*this,
m_items
*this
);
return tagReplacements;
+3
View File
@@ -86,6 +86,9 @@ public:
/// Returns the assembly items.
AssemblyItems const& items() const { return m_items; }
/// Returns the mutable assembly items. Use with care!
AssemblyItems& items() { return m_items; }
int deposit() const { return m_deposit; }
void adjustDeposit(int _adjustment) { m_deposit += _adjustment; assertThrow(m_deposit >= 0, InvalidDeposit, ""); }
void setDeposit(int _deposit) { m_deposit = _deposit; assertThrow(m_deposit >= 0, InvalidDeposit, ""); }
+4 -2
View File
@@ -30,10 +30,12 @@ unsigned ConstantOptimisationMethod::optimiseConstants(
bool _isCreation,
size_t _runs,
solidity::EVMVersion _evmVersion,
Assembly& _assembly,
AssemblyItems& _items
Assembly& _assembly
)
{
// TODO: design the optimiser in a way this is not needed
AssemblyItems& _items = _assembly.items();
unsigned optimisations = 0;
map<AssemblyItem, size_t> pushes;
for (AssemblyItem const& item: _items)
+2 -3
View File
@@ -47,14 +47,13 @@ class ConstantOptimisationMethod
{
public:
/// Tries to optimised how constants are represented in the source code and modifies
/// @a _assembly and its @a _items.
/// @a _assembly.
/// @returns zero if no optimisations could be performed.
static unsigned optimiseConstants(
bool _isCreation,
size_t _runs,
solidity::EVMVersion _evmVersion,
Assembly& _assembly,
AssemblyItems& _items
Assembly& _assembly
);
struct Params