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

Method rationalNumber

libsolidity/ast/TypeProvider.cpp:360–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358}
359
360RationalNumberType const* TypeProvider::rationalNumber(Literal const& _literal)
361{
362 solAssert(_literal.token() == Token::Number, "");
363 std::tuple<bool, rational> validLiteral = RationalNumberType::isValidLiteral(_literal);
364 if (std::get<0>(validLiteral))
365 {
366 Type const* compatibleBytesType = nullptr;
367 if (_literal.isHexNumber())
368 {
369 size_t const digitCount = _literal.valueWithoutUnderscores().length() - 2;
370 if (digitCount % 2 == 0 && (digitCount / 2) <= 32)
371 compatibleBytesType = fixedBytes(static_cast<unsigned>(digitCount / 2));
372 }
373
374 return rationalNumber(std::get<1>(validLiteral), compatibleBytesType);
375 }
376 return nullptr;
377}
378
379StringLiteralType const* TypeProvider::stringLiteral(std::string const& literal)
380{

Callers

nothing calls this directly

Calls 4

isHexNumberMethod · 0.80
tokenMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected