diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2016-11-21 20:23:43 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-07-03 06:37:47 +0800 |
commit | 0494fa98c0c973bf9e8b3dfa4873e1b5744e7715 (patch) | |
tree | fde61fef74bf4f4bc5186b1380775af0854baa14 /libsolidity/codegen/CompilerUtils.cpp | |
parent | d230048dc8385744203528115aa9bb5c0fba4339 (diff) | |
download | dexon-solidity-0494fa98c0c973bf9e8b3dfa4873e1b5744e7715.tar.gz dexon-solidity-0494fa98c0c973bf9e8b3dfa4873e1b5744e7715.tar.zst dexon-solidity-0494fa98c0c973bf9e8b3dfa4873e1b5744e7715.zip |
Add shift helper to CompilerUtils
Diffstat (limited to 'libsolidity/codegen/CompilerUtils.cpp')
-rw-r--r-- | libsolidity/codegen/CompilerUtils.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index a105036f..1da21607 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -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); |