Move Literal to u256 conversions to extra functions

That way we can reuse them at different places
This commit is contained in:
Mathias Baumann
2019-03-05 18:39:27 +01:00
parent 40171c216d
commit 921d52bfcd
4 changed files with 44 additions and 28 deletions
+3 -14
View File
@@ -23,6 +23,7 @@
#include <libyul/optimiser/NameCollector.h>
#include <libyul/AsmAnalysisInfo.h>
#include <libyul/AsmData.h>
#include <libyul/Utilities.h>
#include <liblangutil/Exceptions.h>
@@ -396,20 +397,8 @@ void CodeTransform::operator()(Identifier const& _identifier)
void CodeTransform::operator()(Literal const& _literal)
{
m_assembly.setSourceLocation(_literal.location);
if (_literal.kind == LiteralKind::Number)
m_assembly.appendConstant(u256(_literal.value.str()));
else if (_literal.kind == LiteralKind::Boolean)
{
if (_literal.value == "true"_yulstring)
m_assembly.appendConstant(u256(1));
else
m_assembly.appendConstant(u256(0));
}
else
{
solAssert(_literal.value.str().size() <= 32, "");
m_assembly.appendConstant(u256(h256(_literal.value.str(), h256::FromBinary, h256::AlignLeft)));
}
m_assembly.appendConstant(valueOfLiteral(_literal));
checkStackHeight(&_literal);
}