mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add helpers for the LOG instruction
This commit is contained in:
parent
608f36d77b
commit
21beba76e2
@ -125,8 +125,7 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _
|
|||||||
case Instruction::LOG3:
|
case Instruction::LOG3:
|
||||||
case Instruction::LOG4:
|
case Instruction::LOG4:
|
||||||
{
|
{
|
||||||
unsigned n = unsigned(_item.instruction()) - unsigned(Instruction::LOG0);
|
gas = GasCosts::logGas + GasCosts::logTopicGas * getLogNumber(_item.instruction());
|
||||||
gas = GasCosts::logGas + GasCosts::logTopicGas * n;
|
|
||||||
gas += memoryGas(0, -1);
|
gas += memoryGas(0, -1);
|
||||||
if (u256 const* value = classes.knownConstant(m_state->relativeStackElement(-1)))
|
if (u256 const* value = classes.knownConstant(m_state->relativeStackElement(-1)))
|
||||||
gas += GasCosts::logDataGas * (*value);
|
gas += GasCosts::logDataGas * (*value);
|
||||||
|
@ -218,6 +218,12 @@ inline bool isSwapInstruction(Instruction _inst)
|
|||||||
return Instruction::SWAP1 <= _inst && _inst <= Instruction::SWAP16;
|
return Instruction::SWAP1 <= _inst && _inst <= Instruction::SWAP16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @returns true if the instruction is a LOG
|
||||||
|
inline bool isLogInstruction(Instruction _inst)
|
||||||
|
{
|
||||||
|
return Instruction::LOG0 <= _inst && _inst <= Instruction::LOG4;
|
||||||
|
}
|
||||||
|
|
||||||
/// @returns the number of PUSH Instruction _inst
|
/// @returns the number of PUSH Instruction _inst
|
||||||
inline unsigned getPushNumber(Instruction _inst)
|
inline unsigned getPushNumber(Instruction _inst)
|
||||||
{
|
{
|
||||||
@ -236,6 +242,12 @@ inline unsigned getSwapNumber(Instruction _inst)
|
|||||||
return (byte)_inst - unsigned(Instruction::SWAP1) + 1;
|
return (byte)_inst - unsigned(Instruction::SWAP1) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @returns the number of LOG Instruction _inst
|
||||||
|
inline unsigned getLogNumber(Instruction _inst)
|
||||||
|
{
|
||||||
|
return (byte)_inst - unsigned(Instruction::LOG0);
|
||||||
|
}
|
||||||
|
|
||||||
/// @returns the PUSH<_number> instruction
|
/// @returns the PUSH<_number> instruction
|
||||||
inline Instruction pushInstruction(unsigned _number)
|
inline Instruction pushInstruction(unsigned _number)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user