mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
More uses of shift helper
This commit is contained in:
parent
8fd1d4167d
commit
68b0ac4fdd
@ -353,13 +353,16 @@ void CompilerUtils::splitExternalFunctionType(bool _leftAligned)
|
|||||||
// address (right aligned), function identifier (right aligned)
|
// address (right aligned), function identifier (right aligned)
|
||||||
if (_leftAligned)
|
if (_leftAligned)
|
||||||
{
|
{
|
||||||
m_context << Instruction::DUP1 << (u256(1) << (64 + 32)) << Instruction::SWAP1 << Instruction::DIV;
|
m_context << Instruction::DUP1;
|
||||||
|
rightShiftNumberOnStack(64 + 32, false);
|
||||||
// <input> <address>
|
// <input> <address>
|
||||||
m_context << Instruction::SWAP1 << (u256(1) << 64) << Instruction::SWAP1 << Instruction::DIV;
|
m_context << Instruction::SWAP1;
|
||||||
|
rightShiftNumberOnStack(64, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_context << Instruction::DUP1 << (u256(1) << 32) << Instruction::SWAP1 << Instruction::DIV;
|
m_context << Instruction::DUP1;
|
||||||
|
rightShiftNumberOnStack(32, false);
|
||||||
m_context << ((u256(1) << 160) - 1) << Instruction::AND << Instruction::SWAP1;
|
m_context << ((u256(1) << 160) - 1) << Instruction::AND << Instruction::SWAP1;
|
||||||
}
|
}
|
||||||
m_context << u256(0xffffffffUL) << Instruction::AND;
|
m_context << u256(0xffffffffUL) << Instruction::AND;
|
||||||
@ -383,11 +386,12 @@ void CompilerUtils::pushCombinedFunctionEntryLabel(Declaration const& _function)
|
|||||||
// If there is a runtime context, we have to merge both labels into the same
|
// If there is a runtime context, we have to merge both labels into the same
|
||||||
// stack slot in case we store it in storage.
|
// stack slot in case we store it in storage.
|
||||||
if (CompilerContext* rtc = m_context.runtimeContext())
|
if (CompilerContext* rtc = m_context.runtimeContext())
|
||||||
|
{
|
||||||
|
leftShiftNumberOnStack(32);
|
||||||
m_context <<
|
m_context <<
|
||||||
(u256(1) << 32) <<
|
|
||||||
Instruction::MUL <<
|
|
||||||
rtc->functionEntryLabel(_function).toSubAssemblyTag(m_context.runtimeSub()) <<
|
rtc->functionEntryLabel(_function).toSubAssemblyTag(m_context.runtimeSub()) <<
|
||||||
Instruction::OR;
|
Instruction::OR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerUtils::convertType(
|
void CompilerUtils::convertType(
|
||||||
@ -1029,7 +1033,7 @@ unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords)
|
|||||||
convertType(_type, _type, true);
|
convertType(_type, _type, true);
|
||||||
if (numBytes != 32 && !leftAligned && !_padToWords)
|
if (numBytes != 32 && !leftAligned && !_padToWords)
|
||||||
// shift the value accordingly before storing
|
// shift the value accordingly before storing
|
||||||
m_context << (u256(1) << ((32 - numBytes) * 8)) << Instruction::MUL;
|
leftShiftNumberOnStack((32 - numBytes) * 8);
|
||||||
}
|
}
|
||||||
return numBytes;
|
return numBytes;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user