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

Method incrementCheckedFunction

libsolidity/codegen/YulUtilFunctions.cpp:4216–4237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4214}
4215
4216std::string YulUtilFunctions::incrementCheckedFunction(Type const& _type)
4217{
4218 solAssert(_type.category() == Type::Category::Integer, "");
4219 IntegerType const& type = dynamic_cast<IntegerType const&>(_type);
4220
4221 std::string const functionName = "increment_" + _type.identifier();
4222
4223 return m_functionCollector.createFunction(functionName, [&]() {
4224 return Whiskers(R"(
4225 function <functionName>(value) -> ret {
4226 value := <cleanupFunction>(value)
4227 if eq(value, <maxval>) { <panic>() }
4228 ret := add(value, 1)
4229 }
4230 )")
4231 ("functionName", functionName)
4232 ("maxval", toCompactHexWithPrefix(type.max()))
4233 ("panic", panicFunction(PanicCode::UnderOverflow))
4234 ("cleanupFunction", cleanupFunction(_type))
4235 .render();
4236 });
4237}
4238
4239std::string YulUtilFunctions::incrementWrappingFunction(Type const& _type)
4240{

Callers 2

visitMethod · 0.80
visitMethod · 0.80

Calls 7

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

Tested by

no test coverage detected