| 4214 | } |
| 4215 | |
| 4216 | std::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 | |
| 4239 | std::string YulUtilFunctions::incrementWrappingFunction(Type const& _type) |
| 4240 | { |
no test coverage detected