| 980 | } |
| 981 | |
| 982 | std::string YulUtilFunctions::overflowCheckedIntExpFunction( |
| 983 | IntegerType const& _type, |
| 984 | IntegerType const& _exponentType |
| 985 | ) |
| 986 | { |
| 987 | solAssert(!_exponentType.isSigned(), ""); |
| 988 | |
| 989 | std::string functionName = "checked_exp_" + _type.identifier() + "_" + _exponentType.identifier(); |
| 990 | return m_functionCollector.createFunction(functionName, [&]() { |
| 991 | return |
| 992 | Whiskers(R"( |
| 993 | function <functionName>(base, exponent) -> power { |
| 994 | base := <baseCleanupFunction>(base) |
| 995 | exponent := <exponentCleanupFunction>(exponent) |
| 996 | <?signed> |
| 997 | power := <exp>(base, exponent, <minValue>, <maxValue>) |
| 998 | <!signed> |
| 999 | power := <exp>(base, exponent, <maxValue>) |
| 1000 | </signed> |
| 1001 | |
| 1002 | } |
| 1003 | )") |
| 1004 | ("functionName", functionName) |
| 1005 | ("signed", _type.isSigned()) |
| 1006 | ("exp", _type.isSigned() ? overflowCheckedSignedExpFunction() : overflowCheckedUnsignedExpFunction()) |
| 1007 | ("maxValue", toCompactHexWithPrefix(_type.max())) |
| 1008 | ("minValue", toCompactHexWithPrefix(_type.min())) |
| 1009 | ("baseCleanupFunction", cleanupFunction(_type)) |
| 1010 | ("exponentCleanupFunction", cleanupFunction(_exponentType)) |
| 1011 | .render(); |
| 1012 | }); |
| 1013 | } |
| 1014 | |
| 1015 | std::string YulUtilFunctions::overflowCheckedIntLiteralExpFunction( |
| 1016 | RationalNumberType const& _baseType, |
no test coverage detected