Skip to content

Commit 62cb690

Browse files
committed
Minor refactor
1 parent 1ab98be commit 62cb690

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

Diff for: libsolidity/experimental/codegen/IRGeneratorForStatements.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,16 @@ std::string IRGeneratorForStatements::buildFunctionCall(FunctionDefinition const
228228
return output.str();
229229
}
230230

231-
void IRGeneratorForStatements::declareAssign(IRVariable const& _lhs, IRVariable const& _rhs, bool _declare)
231+
void IRGeneratorForStatements::assign(IRVariable const& _lhs, IRVariable const& _rhs, bool _declare)
232232
{
233233
solAssert(IRGeneratorForStatements::stackSize(m_context, _lhs.type()) == IRGeneratorForStatements::stackSize(m_context, _rhs.type()));
234234
// TODO: conversions for abs and rep for user-defined types as no-ops
235235
if (IRGeneratorForStatements::stackSize(m_context, _lhs.type()) == 1)
236-
m_code << (_declare ? "let ": "") << _lhs.name() << " := " << _rhs.name() << "\n";
236+
m_code << (_declare ? "let " : "") << _lhs.name() << " := " << _rhs.name() << "\n";
237237
else
238238
{
239239
for (size_t i = 0; i < _lhs.stackSize(); ++i)
240-
m_code << (_declare ? "let ": "") << _lhs.stackSlots()[i] << " := " << _rhs.stackSlots()[i] << "\n";
240+
m_code << (_declare ? "let " : "") << _lhs.stackSlots()[i] << " := " << _rhs.stackSlots()[i] << "\n";
241241
}
242242
}
243243

Diff for: libsolidity/experimental/codegen/IRGeneratorForStatements.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,10 @@ class IRGeneratorForStatements: public ASTConstVisitor
115115
/// Default visit will reject all AST nodes that are not explicitly supported.
116116
bool visitNode(ASTNode const& _node) override;
117117

118-
void declareAssign(IRVariable const& _var, IRVariable const& _value, bool _declare);
119118
/// Defines @a _var using the value of @a _value. It declares and assign the variable.
120-
void define(IRVariable const& _var, IRVariable const& _value) { declareAssign(_var, _value, true); }
119+
void define(IRVariable const& _var, IRVariable const& _value) { assign(_var, _value, true); }
121120
/// Assigns @a _var to the value of @a _value. It does not declare the variable.
122-
void assign(IRVariable const& _var, IRVariable const& _value) { declareAssign(_var, _value, false); }
121+
void assign(IRVariable const& _var, IRVariable const& _value, bool _declare = false);
123122
/// Declares variable @a _var.
124123
void declare(IRVariable const& _var);
125124

0 commit comments

Comments
 (0)