Merge pull request #3478 from ethereum/simplifierFormatNumber

Format number nicely in the IULIA simplifier.
This commit is contained in:
chriseth 2018-02-12 21:57:05 +01:00 committed by GitHub
commit bf36821080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -155,6 +155,14 @@ inline std::string formatNumber(bigint const& _value)
return _value.str();
}
inline std::string formatNumber(u256 const& _value)
{
if (_value > 0x1000000)
return toHex(toCompactBigEndian(_value), 2, HexPrefix::Add);
else
return _value.str();
}
inline std::string toCompactHexWithPrefix(u256 val)
{
std::ostringstream ret;

View File

@ -154,7 +154,7 @@ Expression Pattern::toExpression(SourceLocation const& _location) const
if (m_kind == PatternKind::Constant)
{
assertThrow(m_data, OptimizerException, "No match group and no constant value given.");
return Literal{_location, assembly::LiteralKind::Number, m_data->str(), ""};
return Literal{_location, assembly::LiteralKind::Number, formatNumber(*m_data), ""};
}
else if (m_kind == PatternKind::Operation)
{