| 4172 | } |
| 4173 | |
| 4174 | std::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 | |
| 4197 | std::string YulUtilFunctions::decrementWrappingFunction(Type const& _type) |
| 4198 | { |
no test coverage detected