mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add shift helper to CompilerUtils
This commit is contained in:
parent
d230048dc8
commit
0494fa98c0
@ -1007,6 +1007,16 @@ void CompilerUtils::cleanHigherOrderBits(IntegerType const& _typeOnStack)
|
||||
m_context << ((u256(1) << _typeOnStack.numBits()) - 1) << Instruction::AND;
|
||||
}
|
||||
|
||||
void CompilerUtils::leftShiftNumberOnStack(u256 _shiftFactor)
|
||||
{
|
||||
m_context << _shiftFactor << Instruction::MUL;
|
||||
}
|
||||
|
||||
void CompilerUtils::rightShiftNumberOnStack(u256 _shiftFactor, bool _isSigned)
|
||||
{
|
||||
m_context << _shiftFactor << Instruction::SWAP1 << (_isSigned ? Instruction::SDIV : Instruction::DIV);
|
||||
}
|
||||
|
||||
unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords)
|
||||
{
|
||||
unsigned numBytes = _type.calldataEncodedSize(_padToWords);
|
||||
|
@ -176,6 +176,12 @@ public:
|
||||
static unsigned sizeOnStack(std::vector<T> const& _variables);
|
||||
static unsigned sizeOnStack(std::vector<std::shared_ptr<Type const>> const& _variableTypes);
|
||||
|
||||
/// Helper function to shift top value on the stack to the left.
|
||||
void leftShiftNumberOnStack(u256 _shiftFactor);
|
||||
|
||||
/// Helper function to shift top value on the stack to the right.
|
||||
void rightShiftNumberOnStack(u256 _shiftFactor, bool _isSigned = false);
|
||||
|
||||
/// Appends code that computes tha Keccak-256 hash of the topmost stack element of 32 byte type.
|
||||
void computeHashStatic();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user