aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-02-09 21:04:23 +0800
committerchriseth <c@ethdev.com>2017-02-16 17:18:12 +0800
commita5ce81100ef32654e351329fff5cd0e19622798c (patch)
treeb6a64916f0a7806556d220ea38e2b40fc685046f /libsolidity
parent49a919b3e012cfa0f7e0c93c29b93289740e9e44 (diff)
downloaddexon-solidity-a5ce81100ef32654e351329fff5cd0e19622798c.tar.gz
dexon-solidity-a5ce81100ef32654e351329fff5cd0e19622798c.tar.zst
dexon-solidity-a5ce81100ef32654e351329fff5cd0e19622798c.zip
Assembly printer for functions.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/inlineasm/AsmPrinter.cpp18
-rw-r--r--libsolidity/inlineasm/AsmPrinter.h2
2 files changed, 20 insertions, 0 deletions
diff --git a/libsolidity/inlineasm/AsmPrinter.cpp b/libsolidity/inlineasm/AsmPrinter.cpp
index ab2a03ff..a70b0b78 100644
--- a/libsolidity/inlineasm/AsmPrinter.cpp
+++ b/libsolidity/inlineasm/AsmPrinter.cpp
@@ -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())
diff --git a/libsolidity/inlineasm/AsmPrinter.h b/libsolidity/inlineasm/AsmPrinter.h
index 39069d02..a7a1de0a 100644
--- a/libsolidity/inlineasm/AsmPrinter.h
+++ b/libsolidity/inlineasm/AsmPrinter.h
@@ -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);
};