mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Renamed padToWordBoundaries -> padToWords
This commit is contained in:
parent
1c3605362d
commit
0e0d5d47c0
@ -952,9 +952,9 @@ void CompilerUtils::storeStringData(bytesConstRef _data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned CompilerUtils::loadFromMemoryHelper(Type const& _type, bool _fromCalldata, bool _padToWordBoundaries)
|
unsigned CompilerUtils::loadFromMemoryHelper(Type const& _type, bool _fromCalldata, bool _padToWords)
|
||||||
{
|
{
|
||||||
unsigned numBytes = _type.calldataEncodedSize(_padToWordBoundaries);
|
unsigned numBytes = _type.calldataEncodedSize(_padToWords);
|
||||||
bool isExternalFunctionType = false;
|
bool isExternalFunctionType = false;
|
||||||
if (auto const* funType = dynamic_cast<FunctionType const*>(&_type))
|
if (auto const* funType = dynamic_cast<FunctionType const*>(&_type))
|
||||||
if (funType->location() == FunctionType::Location::External)
|
if (funType->location() == FunctionType::Location::External)
|
||||||
@ -993,9 +993,9 @@ void CompilerUtils::cleanHigherOrderBits(IntegerType const& _typeOnStack)
|
|||||||
m_context << ((u256(1) << _typeOnStack.numBits()) - 1) << Instruction::AND;
|
m_context << ((u256(1) << _typeOnStack.numBits()) - 1) << Instruction::AND;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWordBoundaries)
|
unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords)
|
||||||
{
|
{
|
||||||
unsigned numBytes = _type.calldataEncodedSize(_padToWordBoundaries);
|
unsigned numBytes = _type.calldataEncodedSize(_padToWords);
|
||||||
bool leftAligned = _type.category() == Type::Category::FixedBytes;
|
bool leftAligned = _type.category() == Type::Category::FixedBytes;
|
||||||
if (numBytes == 0)
|
if (numBytes == 0)
|
||||||
m_context << Instruction::POP;
|
m_context << Instruction::POP;
|
||||||
@ -1003,7 +1003,7 @@ unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWordBou
|
|||||||
{
|
{
|
||||||
solAssert(numBytes <= 32, "Memory store of more than 32 bytes requested.");
|
solAssert(numBytes <= 32, "Memory store of more than 32 bytes requested.");
|
||||||
convertType(_type, _type, true);
|
convertType(_type, _type, true);
|
||||||
if (numBytes != 32 && !leftAligned && !_padToWordBoundaries)
|
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;
|
m_context << (u256(1) << ((32 - numBytes) * 8)) << Instruction::MUL;
|
||||||
}
|
}
|
||||||
|
@ -52,13 +52,13 @@ public:
|
|||||||
/// @param _offset offset in memory (or calldata)
|
/// @param _offset offset in memory (or calldata)
|
||||||
/// @param _type data type to load
|
/// @param _type data type to load
|
||||||
/// @param _fromCalldata if true, load from calldata, not from memory
|
/// @param _fromCalldata if true, load from calldata, not from memory
|
||||||
/// @param _padToWordBoundaries if true, assume the data is padded to word (32 byte) boundaries
|
/// @param _padToWords if true, assume the data is padded to full words (32 bytes)
|
||||||
/// @returns the number of bytes consumed in memory.
|
/// @returns the number of bytes consumed in memory.
|
||||||
unsigned loadFromMemory(
|
unsigned loadFromMemory(
|
||||||
unsigned _offset,
|
unsigned _offset,
|
||||||
Type const& _type = IntegerType(256),
|
Type const& _type = IntegerType(256),
|
||||||
bool _fromCalldata = false,
|
bool _fromCalldata = false,
|
||||||
bool _padToWordBoundaries = false
|
bool _padToWords = false
|
||||||
);
|
);
|
||||||
/// Dynamic version of @see loadFromMemory, expects the memory offset on the stack.
|
/// Dynamic version of @see loadFromMemory, expects the memory offset on the stack.
|
||||||
/// Stack pre: memory_offset
|
/// Stack pre: memory_offset
|
||||||
@ -66,7 +66,7 @@ public:
|
|||||||
void loadFromMemoryDynamic(
|
void loadFromMemoryDynamic(
|
||||||
Type const& _type,
|
Type const& _type,
|
||||||
bool _fromCalldata = false,
|
bool _fromCalldata = false,
|
||||||
bool _padToWordBoundaries = true,
|
bool _padToWords = true,
|
||||||
bool _keepUpdatedMemoryOffset = true
|
bool _keepUpdatedMemoryOffset = true
|
||||||
);
|
);
|
||||||
/// Stores a 256 bit integer from stack in memory.
|
/// Stores a 256 bit integer from stack in memory.
|
||||||
@ -76,11 +76,11 @@ public:
|
|||||||
/// Dynamic version of @see storeInMemory, expects the memory offset below the value on the stack
|
/// Dynamic version of @see storeInMemory, expects the memory offset below the value on the stack
|
||||||
/// and also updates that. For reference types, only copies the data pointer. Fails for
|
/// and also updates that. For reference types, only copies the data pointer. Fails for
|
||||||
/// non-memory-references.
|
/// non-memory-references.
|
||||||
/// @param _padToWordBoundaries if true, adds zeros to pad to multiple of 32 bytes. Array elements
|
/// @param _padToWords if true, adds zeros to pad to multiple of 32 bytes. Array elements
|
||||||
/// are always padded (except for byte arrays), regardless of this parameter.
|
/// are always padded (except for byte arrays), regardless of this parameter.
|
||||||
/// Stack pre: memory_offset value...
|
/// Stack pre: memory_offset value...
|
||||||
/// Stack post: (memory_offset+length)
|
/// Stack post: (memory_offset+length)
|
||||||
void storeInMemoryDynamic(Type const& _type, bool _padToWordBoundaries = true);
|
void storeInMemoryDynamic(Type const& _type, bool _padToWords = true);
|
||||||
|
|
||||||
/// Copies values (of types @a _givenTypes) given on the stack to a location in memory given
|
/// Copies values (of types @a _givenTypes) given on the stack to a location in memory given
|
||||||
/// at the stack top, encoding them according to the ABI as the given types @a _targetTypes.
|
/// at the stack top, encoding them according to the ABI as the given types @a _targetTypes.
|
||||||
@ -88,7 +88,7 @@ public:
|
|||||||
/// Stack pre: <v1> <v2> ... <vn> <memptr>
|
/// Stack pre: <v1> <v2> ... <vn> <memptr>
|
||||||
/// Stack post: <memptr_updated>
|
/// Stack post: <memptr_updated>
|
||||||
/// Does not touch the memory-free pointer.
|
/// Does not touch the memory-free pointer.
|
||||||
/// @param _padToWordBoundaries if false, all values are concatenated without padding.
|
/// @param _padToWords if false, all values are concatenated without padding.
|
||||||
/// @param _copyDynamicDataInPlace if true, dynamic types is stored (without length)
|
/// @param _copyDynamicDataInPlace if true, dynamic types is stored (without length)
|
||||||
/// together with fixed-length data.
|
/// together with fixed-length data.
|
||||||
/// @param _encodeAsLibraryTypes if true, encodes for a library function, e.g. does not
|
/// @param _encodeAsLibraryTypes if true, encodes for a library function, e.g. does not
|
||||||
@ -98,7 +98,7 @@ public:
|
|||||||
void encodeToMemory(
|
void encodeToMemory(
|
||||||
TypePointers const& _givenTypes = {},
|
TypePointers const& _givenTypes = {},
|
||||||
TypePointers const& _targetTypes = {},
|
TypePointers const& _targetTypes = {},
|
||||||
bool _padToWordBoundaries = true,
|
bool _padToWords = true,
|
||||||
bool _copyDynamicDataInPlace = false,
|
bool _copyDynamicDataInPlace = false,
|
||||||
bool _encodeAsLibraryTypes = false
|
bool _encodeAsLibraryTypes = false
|
||||||
);
|
);
|
||||||
@ -193,9 +193,9 @@ private:
|
|||||||
void cleanHigherOrderBits(IntegerType const& _typeOnStack);
|
void cleanHigherOrderBits(IntegerType const& _typeOnStack);
|
||||||
|
|
||||||
/// Prepares the given type for storing in memory by shifting it if necessary.
|
/// Prepares the given type for storing in memory by shifting it if necessary.
|
||||||
unsigned prepareMemoryStore(Type const& _type, bool _padToWordBoundaries);
|
unsigned prepareMemoryStore(Type const& _type, bool _padToWords);
|
||||||
/// Loads type from memory assuming memory offset is on stack top.
|
/// Loads type from memory assuming memory offset is on stack top.
|
||||||
unsigned loadFromMemoryHelper(Type const& _type, bool _fromCalldata, bool _padToWordBoundaries);
|
unsigned loadFromMemoryHelper(Type const& _type, bool _fromCalldata, bool _padToWords);
|
||||||
|
|
||||||
CompilerContext& m_context;
|
CompilerContext& m_context;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user