| 878 | } |
| 879 | |
| 880 | std::string YulUtilFunctions::wrappingIntDivFunction(IntegerType const& _type) |
| 881 | { |
| 882 | std::string functionName = "wrapping_div_" + _type.identifier(); |
| 883 | return m_functionCollector.createFunction(functionName, [&]() { |
| 884 | return |
| 885 | Whiskers(R"( |
| 886 | function <functionName>(x, y) -> r { |
| 887 | x := <cleanupFunction>(x) |
| 888 | y := <cleanupFunction>(y) |
| 889 | if iszero(y) { <error>() } |
| 890 | r := <?signed>s</signed>div(x, y) |
| 891 | } |
| 892 | )") |
| 893 | ("functionName", functionName) |
| 894 | ("cleanupFunction", cleanupFunction(_type)) |
| 895 | ("signed", _type.isSigned()) |
| 896 | ("error", panicFunction(PanicCode::DivisionByZero)) |
| 897 | .render(); |
| 898 | }); |
| 899 | } |
| 900 | |
| 901 | std::string YulUtilFunctions::intModFunction(IntegerType const& _type) |
| 902 | { |
no test coverage detected