[libyul] ObjectParser: Enables the use of custom source mapping via @use-src.

This commit is contained in:
Christian Parpart
2021-07-27 16:46:47 +02:00
parent e3184c737a
commit 3755210b7b
7 changed files with 263 additions and 9 deletions
+18
View File
@@ -177,4 +177,22 @@ inline std::string formatNumberReadable(
return str;
}
/// Safely converts an usigned integer as string into an unsigned int type.
///
/// @return the converted number or nullopt in case of an failure (including if it would not fit).
inline std::optional<unsigned> toUnsignedInt(std::string const& _value)
{
try
{
auto const ulong = stoul(_value);
if (ulong > std::numeric_limits<unsigned>::max())
return std::nullopt;
return static_cast<unsigned>(ulong);
}
catch (...)
{
return std::nullopt;
}
}
}