MCPcopy Create free account
hub / github.com/argotorg/solidity / decrementCheckedFunction

Method decrementCheckedFunction

libsolidity/codegen/YulUtilFunctions.cpp:4174–4195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4172}
4173
4174std::string YulUtilFunctions::decrementCheckedFunction(Type const& _type)
4175{
4176 solAssert(_type.category() == Type::Category::Integer, "");
4177 IntegerType const& type = dynamic_cast<IntegerType const&>(_type);
4178
4179 std::string const functionName = "decrement_" + _type.identifier();
4180
4181 return m_functionCollector.createFunction(functionName, [&]() {
4182 return Whiskers(R"(
4183 function <functionName>(value) -> ret {
4184 value := <cleanupFunction>(value)
4185 if eq(value, <minval>) { <panic>() }
4186 ret := sub(value, 1)
4187 }
4188 )")
4189 ("functionName", functionName)
4190 ("panic", panicFunction(PanicCode::UnderOverflow))
4191 ("minval", toCompactHexWithPrefix(type.min()))
4192 ("cleanupFunction", cleanupFunction(_type))
4193 .render();
4194 });
4195}
4196
4197std::string YulUtilFunctions::decrementWrappingFunction(Type const& _type)
4198{

Callers 2

visitMethod · 0.80
visitMethod · 0.80

Calls 7

WhiskersClass · 0.85
toCompactHexWithPrefixFunction · 0.85
identifierMethod · 0.80
renderMethod · 0.80
categoryMethod · 0.45
createFunctionMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected