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

Method overflowCheckedIntExpFunction

libsolidity/codegen/YulUtilFunctions.cpp:982–1013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

980}
981
982std::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
1015std::string YulUtilFunctions::overflowCheckedIntLiteralExpFunction(
1016 RationalNumberType const& _baseType,

Callers 2

appendExpOperatorCodeMethod · 0.80
visitMethod · 0.80

Calls 8

WhiskersClass · 0.85
toCompactHexWithPrefixFunction · 0.85
identifierMethod · 0.80
renderMethod · 0.80
maxMethod · 0.80
isSignedMethod · 0.45
createFunctionMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected