mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[libsolidity] TypeProvider: adds explicit uint256() accessor and removes default params in integerType(...).
This commit is contained in:
1 parent
59d4f54729
commit
58a45f2cb6
13 files changed
+57
-54
No files matched your search
@@ -186,7 +186,7 @@ void CompilerUtils::loadFromMemoryDynamic(
|
||||
|
||||
void CompilerUtils::storeInMemory(unsigned _offset)
|
||||
{
|
||||
unsigned numBytes = prepareMemoryStore(*TypeProvider::integerType(), true);
|
||||
unsigned numBytes = prepareMemoryStore(*TypeProvider::uint256(), true);
|
||||
if (numBytes > 0)
|
||||
m_context << u256(_offset) << Instruction::MSTORE;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBound
|
||||
ref->location() == DataLocation::Memory,
|
||||
"Only in-memory reference type can be stored."
|
||||
);
|
||||
storeInMemoryDynamic(*TypeProvider::integerType(), _padToWordBoundaries);
|
||||
storeInMemoryDynamic(*TypeProvider::uint256(), _padToWordBoundaries);
|
||||
}
|
||||
else if (auto str = dynamic_cast<StringLiteralType const*>(&_type))
|
||||
{
|
||||
@@ -316,7 +316,7 @@ void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMem
|
||||
if (calldataType->isDynamicallySized())
|
||||
{
|
||||
// put on stack: data_pointer length
|
||||
loadFromMemoryDynamic(*TypeProvider::integerType(), !_fromMemory);
|
||||
loadFromMemoryDynamic(*TypeProvider::uint256(), !_fromMemory);
|
||||
m_context << Instruction::SWAP1;
|
||||
// stack: input_end base_offset next_pointer data_offset
|
||||
m_context.appendInlineAssembly("{ if gt(data_offset, 0x100000000) { revert(0, 0) } }", {"data_offset"});
|
||||
@@ -327,7 +327,7 @@ void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMem
|
||||
{"input_end", "base_offset", "next_ptr", "array_head_ptr"}
|
||||
);
|
||||
// retrieve length
|
||||
loadFromMemoryDynamic(*TypeProvider::integerType(), !_fromMemory, true);
|
||||
loadFromMemoryDynamic(*TypeProvider::uint256(), !_fromMemory, true);
|
||||
// stack: input_end base_offset next_pointer array_length data_pointer
|
||||
m_context << Instruction::SWAP2;
|
||||
// stack: input_end base_offset data_pointer array_length next_pointer
|
||||
@@ -483,7 +483,7 @@ void CompilerUtils::encodeToMemory(
|
||||
{
|
||||
auto const& strType = dynamic_cast<StringLiteralType const&>(*_givenTypes[i]);
|
||||
m_context << u256(strType.value().size());
|
||||
storeInMemoryDynamic(*TypeProvider::integerType(), true);
|
||||
storeInMemoryDynamic(*TypeProvider::uint256(), true);
|
||||
// stack: ... <end_of_mem'>
|
||||
storeInMemoryDynamic(strType, _padToWordBoundaries);
|
||||
}
|
||||
@@ -498,7 +498,7 @@ void CompilerUtils::encodeToMemory(
|
||||
m_context << dupInstruction(1 + arrayType.sizeOnStack());
|
||||
ArrayUtils(m_context).retrieveLength(arrayType, 1);
|
||||
// stack: ... <end_of_mem> <value...> <end_of_mem'> <length>
|
||||
storeInMemoryDynamic(*TypeProvider::integerType(), true);
|
||||
storeInMemoryDynamic(*TypeProvider::uint256(), true);
|
||||
// stack: ... <end_of_mem> <value...> <end_of_mem''>
|
||||
// copy the new memory pointer
|
||||
m_context << swapInstruction(arrayType.sizeOnStack() + 1) << Instruction::POP;
|
||||
@@ -869,7 +869,7 @@ void CompilerUtils::convertType(
|
||||
allocateMemory(storageSize);
|
||||
// stack: mempos
|
||||
m_context << Instruction::DUP1 << u256(data.size());
|
||||
storeInMemoryDynamic(*TypeProvider::integerType());
|
||||
storeInMemoryDynamic(*TypeProvider::uint256());
|
||||
// stack: mempos datapos
|
||||
storeStringData(data);
|
||||
}
|
||||
@@ -918,7 +918,7 @@ void CompilerUtils::convertType(
|
||||
if (targetType.isDynamicallySized())
|
||||
{
|
||||
m_context << Instruction::DUP2;
|
||||
storeInMemoryDynamic(*TypeProvider::integerType());
|
||||
storeInMemoryDynamic(*TypeProvider::uint256());
|
||||
}
|
||||
// stack: <mem start> <source ref> (variably sized) <length> <mem data pos>
|
||||
if (targetType.baseType()->isValueType())
|
||||
@@ -1321,7 +1321,7 @@ void CompilerUtils::storeStringData(bytesConstRef _data)
|
||||
for (unsigned i = 0; i < _data.size(); i += 32)
|
||||
{
|
||||
m_context << h256::Arith(h256(_data.cropped(i), h256::AlignLeft));
|
||||
storeInMemoryDynamic(*TypeProvider::integerType());
|
||||
storeInMemoryDynamic(*TypeProvider::uint256());
|
||||
}
|
||||
m_context << Instruction::POP;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user