mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Assembly printer for functions.
This commit is contained in:
parent
49a919b3e0
commit
a5ce81100e
@ -112,6 +112,24 @@ string AsmPrinter::operator()(assembly::VariableDeclaration const& _variableDecl
|
||||
return "let " + _variableDeclaration.name + " := " + boost::apply_visitor(*this, *_variableDeclaration.value);
|
||||
}
|
||||
|
||||
string AsmPrinter::operator()(assembly::FunctionDefinition const& _functionDefinition)
|
||||
{
|
||||
string out = "function " + _functionDefinition.name + "(" + boost::algorithm::join(_functionDefinition.arguments, ", ") + ")";
|
||||
if (!_functionDefinition.returns.empty())
|
||||
out += " -> (" + boost::algorithm::join(_functionDefinition.returns, ", ") + ")";
|
||||
return out + "\n" + (*this)(_functionDefinition.body);
|
||||
}
|
||||
|
||||
string AsmPrinter::operator()(assembly::FunctionCall const& _functionCall)
|
||||
{
|
||||
return
|
||||
(*this)(_functionCall.functionName) + "(" +
|
||||
boost::algorithm::join(
|
||||
_functionCall.arguments | boost::adaptors::transformed(boost::apply_visitor(*this)),
|
||||
", " ) +
|
||||
")";
|
||||
}
|
||||
|
||||
string AsmPrinter::operator()(Block const& _block)
|
||||
{
|
||||
if (_block.statements.empty())
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
std::string operator()(assembly::Assignment const& _assignment);
|
||||
std::string operator()(assembly::FunctionalAssignment const& _functionalAssignment);
|
||||
std::string operator()(assembly::VariableDeclaration const& _variableDeclaration);
|
||||
std::string operator()(assembly::FunctionDefinition const& _functionDefinition);
|
||||
std::string operator()(assembly::FunctionCall const& _functionCall);
|
||||
std::string operator()(assembly::Block const& _block);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user