@@ -805,8 +805,8 @@ bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
805
805
if (auto type = dynamic_cast <IntegerType const *>(commonType))
806
806
isSigned = type->isSigned ();
807
807
808
- string args = expressionAsType (_binOp.leftExpression (), *commonType, true );
809
- args += " , " + expressionAsType (_binOp.rightExpression (), *commonType, true );
808
+ string args = expressionAsCleanedType (_binOp.leftExpression (), *commonType);
809
+ args += " , " + expressionAsCleanedType (_binOp.rightExpression (), *commonType);
810
810
811
811
auto functionType = dynamic_cast <FunctionType const *>(commonType);
812
812
solAssert (functionType ? (op == Token::Equal || op == Token::NotEqual) : true , " Invalid function pointer comparison!" );
@@ -1037,7 +1037,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
1037
1037
else
1038
1038
{
1039
1039
solAssert (parameterTypes[i]->sizeOnStack () == 1 , " " );
1040
- indexedArgs.emplace_back (convert (arg, *paramTypes [i], true ));
1040
+ indexedArgs.emplace_back (convertAndCleanup (arg, *parameterTypes [i]));
1041
1041
}
1042
1042
}
1043
1043
else
@@ -2727,32 +2727,43 @@ void IRGeneratorForStatements::assignInternalFunctionIDIfNotCalledDirectly(
2727
2727
m_context.addToInternalDispatch (_referencedFunction);
2728
2728
}
2729
2729
2730
- IRVariable IRGeneratorForStatements::convert (IRVariable const & _from, Type const & _to, bool _forceCleanup )
2730
+ IRVariable IRGeneratorForStatements::convert (IRVariable const & _from, Type const & _to)
2731
2731
{
2732
- if (_from.type () == _to && !_forceCleanup )
2732
+ if (_from.type () == _to)
2733
2733
return _from;
2734
2734
else
2735
2735
{
2736
2736
IRVariable converted (m_context.newYulVariable (), _to);
2737
- define (converted, _from, _forceCleanup );
2737
+ define (converted, _from);
2738
2738
return converted;
2739
2739
}
2740
2740
}
2741
2741
2742
- std::string IRGeneratorForStatements::expressionAsType (Expression const & _expression, Type const & _to, bool _forceCleanup)
2742
+ IRVariable IRGeneratorForStatements::convertAndCleanup (IRVariable const & _from, Type const & _to)
2743
+ {
2744
+ IRVariable converted (m_context.newYulVariable (), _to);
2745
+ defineAndCleanup (converted, _from);
2746
+ return converted;
2747
+ }
2748
+
2749
+ std::string IRGeneratorForStatements::expressionAsType (Expression const & _expression, Type const & _to)
2743
2750
{
2744
2751
IRVariable from (_expression);
2745
2752
if (from.type () == _to)
2746
- {
2747
- if (_forceCleanup)
2748
- return m_utils.cleanupFunction (_to) + " (" + from.commaSeparatedList () + " )" ;
2749
- else
2750
- return from.commaSeparatedList ();
2751
- }
2753
+ return from.commaSeparatedList ();
2752
2754
else
2753
2755
return m_utils.conversionFunction (from.type (), _to) + " (" + from.commaSeparatedList () + " )" ;
2754
2756
}
2755
2757
2758
+ std::string IRGeneratorForStatements::expressionAsCleanedType (Expression const & _expression, Type const & _to)
2759
+ {
2760
+ IRVariable from (_expression);
2761
+ if (from.type () == _to)
2762
+ return m_utils.cleanupFunction (_to) + " (" + expressionAsType (_expression, _to) + " )" ;
2763
+ else
2764
+ return expressionAsType (_expression, _to) ;
2765
+ }
2766
+
2756
2767
std::ostream& IRGeneratorForStatements::define (IRVariable const & _var)
2757
2768
{
2758
2769
if (_var.type ().sizeOnStack () > 0 )
0 commit comments