aboutsummaryrefslogtreecommitdiffstats
path: root/CompilerUtils.h
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-01-09 07:58:32 +0800
committerChristian <c@ethdev.com>2015-01-10 01:20:51 +0800
commitfe16922087ef41f157ef8661a9295aa1539796a5 (patch)
treee11a1111c08a862c72f9de92b2d47f6d81ea3bcd /CompilerUtils.h
parent396f638ce19206144ce32dcf3926fc13fa9a89b7 (diff)
downloaddexon-solidity-fe16922087ef41f157ef8661a9295aa1539796a5.tar.gz
dexon-solidity-fe16922087ef41f157ef8661a9295aa1539796a5.tar.zst
dexon-solidity-fe16922087ef41f157ef8661a9295aa1539796a5.zip
Padding for ABI types.
Diffstat (limited to 'CompilerUtils.h')
-rw-r--r--CompilerUtils.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/CompilerUtils.h b/CompilerUtils.h
index 6bd8d315..b5a69528 100644
--- a/CompilerUtils.h
+++ b/CompilerUtils.h
@@ -40,12 +40,23 @@ public:
/// @param _bytes number of bytes to load
/// @param _leftAligned if true, store left aligned on stack (otherwise right aligned)
/// @param _fromCalldata if true, load from calldata, not from memory
- void loadFromMemory(unsigned _offset, unsigned _bytes = 32, bool _leftAligned = false, bool _fromCalldata = false);
+ /// @param _padToWordBoundaries if true, assume the data is padded to word (32 byte) boundaries
+ /// @returns the number of bytes consumed in memory (can be different from _bytes if
+ /// _padToWordBoundaries is true)
+ unsigned loadFromMemory(unsigned _offset, unsigned _bytes = 32, bool _leftAligned = false,
+ bool _fromCalldata = false, bool _padToWordBoundaries = false);
/// Stores data from stack in memory.
/// @param _offset offset in memory
/// @param _bytes number of bytes to store
/// @param _leftAligned if true, data is left aligned on stack (otherwise right aligned)
- void storeInMemory(unsigned _offset, unsigned _bytes = 32, bool _leftAligned = false);
+ /// @param _padToWordBoundaries if true, pad the data to word (32 byte) boundaries
+ /// @returns the number of bytes written to memory (can be different from _bytes if
+ /// _padToWordBoundaries is true)
+ unsigned storeInMemory(unsigned _offset, unsigned _bytes = 32, bool _leftAligned = false,
+ bool _padToWordBoundaries = false);
+ /// @returns _size rounded up to the next multiple of 32 (the number of bytes occupied in the
+ /// padded calldata)
+ static unsigned getPaddedSize(unsigned _size) { return ((_size + 31) / 32) * 32; }
/// Moves the value that is at the top of the stack to a stack variable.
void moveToStackVariable(VariableDeclaration const& _variable);