mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Define wasm::Type enum and use it for import parameters and result
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
|
||||
#include <libyul/backends/wasm/TextTransform.h>
|
||||
|
||||
#include <libyul/Exceptions.h>
|
||||
|
||||
#include <libsolutil/StringUtils.h>
|
||||
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
@@ -44,9 +46,9 @@ string TextTransform::run(wasm::Module const& _module)
|
||||
{
|
||||
ret += " (import \"" + imp.module + "\" \"" + imp.externalName + "\" (func $" + imp.internalName;
|
||||
if (!imp.paramTypes.empty())
|
||||
ret += " (param" + joinHumanReadablePrefixed(imp.paramTypes, " ", " ") + ")";
|
||||
ret += " (param" + joinHumanReadablePrefixed(imp.paramTypes | boost::adaptors::transformed(encodeType), " ", " ") + ")";
|
||||
if (imp.returnType)
|
||||
ret += " (result " + *imp.returnType + ")";
|
||||
ret += " (result " + encodeType(*imp.returnType) + ")";
|
||||
ret += "))\n";
|
||||
}
|
||||
|
||||
@@ -193,3 +195,13 @@ string TextTransform::joinTransformed(vector<wasm::Expression> const& _expressio
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
string TextTransform::encodeType(wasm::Type _type)
|
||||
{
|
||||
if (_type == wasm::Type::i32)
|
||||
return "i32";
|
||||
else if (_type == wasm::Type::i64)
|
||||
return "i64";
|
||||
else
|
||||
yulAssert(false, "Invalid wasm type");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user