diff options
| author | chriseth <chris@ethereum.org> | 2018-05-08 04:34:31 +0800 |
|---|---|---|
| committer | chriseth <chris@ethereum.org> | 2018-05-16 15:48:03 +0800 |
| commit | 894122c508c4de07553c7e2908ae36821e812a9f (patch) | |
| tree | 694d7cccbe796d33f63bfca3c25eecb9021cb1a4 /libsolidity/ast | |
| parent | 8b98ff470ccb11fbe0e7c1729db5958355c2f84a (diff) | |
| download | dexon-solidity-894122c508c4de07553c7e2908ae36821e812a9f.tar dexon-solidity-894122c508c4de07553c7e2908ae36821e812a9f.tar.gz dexon-solidity-894122c508c4de07553c7e2908ae36821e812a9f.tar.bz2 dexon-solidity-894122c508c4de07553c7e2908ae36821e812a9f.tar.lz dexon-solidity-894122c508c4de07553c7e2908ae36821e812a9f.tar.xz dexon-solidity-894122c508c4de07553c7e2908ae36821e812a9f.tar.zst dexon-solidity-894122c508c4de07553c7e2908ae36821e812a9f.zip | |
Warn/enforce single bytes argument for certain builtins (hashing functions).
In 0.5.0 mode, only accept a single bytes argument for ``.call``,
``keccak256`` and others and do not pad when encoding.
Diffstat (limited to 'libsolidity/ast')
| -rw-r--r-- | libsolidity/ast/Types.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 4884696d..95821634 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -1058,6 +1058,22 @@ public: /// true iff arguments are to be padded to multiples of 32 bytes for external calls bool padArguments() const { return !(m_kind == Kind::SHA3 || m_kind == Kind::SHA256 || m_kind == Kind::RIPEMD160 || m_kind == Kind::ABIEncodePacked); } bool takesArbitraryParameters() const { return m_arbitraryParameters; } + /// true iff the function takes a single bytes parameter and it is passed on without padding. + /// @todo until 0.5.0, this is just a "recommendation". + bool takesSinglePackedBytesParameter() const + { + // @todo add the call kinds here with 0.5.0 and perhaps also log0. + switch (m_kind) + { + case FunctionType::Kind::SHA3: + case FunctionType::Kind::SHA256: + case FunctionType::Kind::RIPEMD160: + return true; + default: + return false; + } + } + bool gasSet() const { return m_gasSet; } bool valueSet() const { return m_valueSet; } bool bound() const { return m_bound; } |
