aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/CompilerUtils.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-04-06 21:14:55 +0800
committerchriseth <chris@ethereum.org>2018-04-12 19:09:38 +0800
commit4faa839813ce76fc87f99b002aad6cadd2b784e1 (patch)
treec461378847bc2ad15f0cc85fc2100a26b9ee9902 /libsolidity/codegen/CompilerUtils.cpp
parent338a875134f2e41e9a7e254cc3f7d87c7f4d462e (diff)
downloaddexon-solidity-4faa839813ce76fc87f99b002aad6cadd2b784e1.tar.gz
dexon-solidity-4faa839813ce76fc87f99b002aad6cadd2b784e1.tar.zst
dexon-solidity-4faa839813ce76fc87f99b002aad6cadd2b784e1.zip
Use error signature for revert data.
Diffstat (limited to 'libsolidity/codegen/CompilerUtils.cpp')
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 34337d7d..b4550153 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -78,6 +78,20 @@ void CompilerUtils::toSizeAfterFreeMemoryPointer()
m_context << Instruction::SWAP1;
}
+void CompilerUtils::revertWithStringData(Type const& _argumentType)
+{
+ solAssert(_argumentType.isImplicitlyConvertibleTo(*Type::fromElementaryTypeName("string memory")), "");
+ fetchFreeMemoryPointer();
+ m_context << (u256(FixedHash<4>::Arith(FixedHash<4>(dev::keccak256("Error(string)")))) << (256 - 32));
+ m_context << Instruction::DUP2 << Instruction::MSTORE;
+ m_context << u256(4) << Instruction::ADD;
+ // Stack: <string data> <mem pos of encoding start>
+ abiEncode({_argumentType.shared_from_this()}, {make_shared<ArrayType>(DataLocation::Memory, true)});
+ toSizeAfterFreeMemoryPointer();
+ m_context << Instruction::REVERT;
+ m_context.adjustStackOffset(_argumentType.sizeOnStack());
+}
+
unsigned CompilerUtils::loadFromMemory(
unsigned _offset,
Type const& _type,