aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/CompilerUtils.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-04-06 22:25:13 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-05-01 03:34:43 +0800
commit2968639406888d97bfae70e4adf41674ac60fd83 (patch)
treecabaf0aff5bfd64fb067b6b537534fc851bc1b41 /libsolidity/codegen/CompilerUtils.cpp
parent52c94418795f829c4a225fdf4742eec7a1961232 (diff)
downloaddexon-solidity-2968639406888d97bfae70e4adf41674ac60fd83.tar.gz
dexon-solidity-2968639406888d97bfae70e4adf41674ac60fd83.tar.zst
dexon-solidity-2968639406888d97bfae70e4adf41674ac60fd83.zip
Removed signed shift right from the utilities.
Diffstat (limited to 'libsolidity/codegen/CompilerUtils.cpp')
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 45ad1f47..48b77eb3 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -599,15 +599,15 @@ void CompilerUtils::splitExternalFunctionType(bool _leftAligned)
if (_leftAligned)
{
m_context << Instruction::DUP1;
- rightShiftNumberOnStack(64 + 32, false);
+ rightShiftNumberOnStack(64 + 32);
// <input> <address>
m_context << Instruction::SWAP1;
- rightShiftNumberOnStack(64, false);
+ rightShiftNumberOnStack(64);
}
else
{
m_context << Instruction::DUP1;
- rightShiftNumberOnStack(32, false);
+ rightShiftNumberOnStack(32);
m_context << ((u256(1) << 160) - 1) << Instruction::AND << Instruction::SWAP1;
}
m_context << u256(0xffffffffUL) << Instruction::AND;
@@ -675,7 +675,7 @@ void CompilerUtils::convertType(
// conversion from bytes to integer. no need to clean the high bit
// only to shift right because of opposite alignment
IntegerType const& targetIntegerType = dynamic_cast<IntegerType const&>(_targetType);
- rightShiftNumberOnStack(256 - typeOnStack.numBytes() * 8, false);
+ rightShiftNumberOnStack(256 - typeOnStack.numBytes() * 8);
if (targetIntegerType.numBits() < typeOnStack.numBytes() * 8)
convertType(IntegerType(typeOnStack.numBytes() * 8), _targetType, _cleanupNeeded);
}
@@ -1242,7 +1242,7 @@ unsigned CompilerUtils::loadFromMemoryHelper(Type const& _type, bool _fromCallda
bool leftAligned = _type.category() == Type::Category::FixedBytes;
// add leading or trailing zeros by dividing/multiplying depending on alignment
int shiftFactor = (32 - numBytes) * 8;
- rightShiftNumberOnStack(shiftFactor, false);
+ rightShiftNumberOnStack(shiftFactor);
if (leftAligned)
leftShiftNumberOnStack(shiftFactor);
}
@@ -1271,14 +1271,14 @@ void CompilerUtils::leftShiftNumberOnStack(unsigned _bits)
m_context << (u256(1) << _bits) << Instruction::MUL;
}
-void CompilerUtils::rightShiftNumberOnStack(unsigned _bits, bool _isSigned)
+void CompilerUtils::rightShiftNumberOnStack(unsigned _bits)
{
solAssert(_bits < 256, "");
- // NOTE: SAR rounds differently than SDIV
- if (m_context.evmVersion().hasBitwiseShifting() && !_isSigned)
+ // NOTE: If we add signed right shift, SAR rounds differently than SDIV
+ if (m_context.evmVersion().hasBitwiseShifting())
m_context << _bits << Instruction::SHR;
else
- m_context << (u256(1) << _bits) << Instruction::SWAP1 << (_isSigned ? Instruction::SDIV : Instruction::DIV);
+ m_context << (u256(1) << _bits) << Instruction::SWAP1 << Instruction::DIV;
}
unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords)