From 0831f1bff2273caec7235b2731b7a6cbb3fa060a Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Mon, 21 Aug 2023 16:18:21 -0300 Subject: [PATCH] fixup! [Refactor] Add AssemblyItem as param to copyRoutine --- libevmasm/ConstantOptimiser.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libevmasm/ConstantOptimiser.cpp b/libevmasm/ConstantOptimiser.cpp index 70fbb0ef7..360fb781f 100644 --- a/libevmasm/ConstantOptimiser.cpp +++ b/libevmasm/ConstantOptimiser.cpp @@ -159,6 +159,11 @@ AssemblyItems CodeCopyMethod::execute(Assembly& _assembly) const AssemblyItems CodeCopyMethod::copyRoutine(AssemblyItem* _pushData) const { + if (_pushData) + assertThrow(_pushData->type() == PushData, OptimizerException, "Invalid Assembly Item."); + + AssemblyItem dataUsed = _pushData ? *_pushData : AssemblyItem(PushData, u256(1) << 16); + // PUSH0 is cheaper than PUSHn/DUP/SWAP. if (m_params.evmVersion.hasPush0()) { @@ -171,7 +176,7 @@ AssemblyItems CodeCopyMethod::copyRoutine(AssemblyItem* _pushData) const // codecopy(0, , 32) u256(32), - (_pushData ? *_pushData : AssemblyItem(PushData, u256(1) << 16)), + dataUsed, u256(0), Instruction::CODECOPY, @@ -201,7 +206,7 @@ AssemblyItems CodeCopyMethod::copyRoutine(AssemblyItem* _pushData) const // codecopy(0, , 32) u256(32), - (_pushData ? *_pushData : AssemblyItem(PushData, u256(1) << 16)), + dataUsed, Instruction::DUP4, Instruction::CODECOPY,