summaryrefslogtreecommitdiff
path: root/src/asm_v_wasm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/asm_v_wasm.h')
-rw-r--r--src/asm_v_wasm.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/asm_v_wasm.h b/src/asm_v_wasm.h
index 66601cf10..95b4cbbca 100644
--- a/src/asm_v_wasm.h
+++ b/src/asm_v_wasm.h
@@ -29,8 +29,17 @@ AsmType wasmToAsmType(Type type);
char getSig(Type type);
-std::string getSig(const FunctionType* type);
+template<typename ListType>
+std::string getSig(const ListType& params, Type result) {
+ std::string ret;
+ ret += getSig(result);
+ for (auto param : params) {
+ ret += getSig(param);
+ }
+ return ret;
+}
+std::string getSig(const FunctionType* type);
std::string getSig(Function* func);
template<typename T,
@@ -67,9 +76,18 @@ std::string getSigFromStructs(Type result, const ListType& operands) {
Type sigToType(char sig);
-FunctionType sigToFunctionType(std::string sig);
+FunctionType sigToFunctionType(const std::string& sig);
+
+FunctionType*
+ensureFunctionType(const std::string& sig, Module* wasm, Name name = Name());
-FunctionType* ensureFunctionType(std::string sig, Module* wasm);
+template<typename ListType>
+FunctionType* ensureFunctionType(const ListType& params,
+ Type result,
+ Module* wasm,
+ Name name = Name()) {
+ return ensureFunctionType(getSig(params, result), wasm, name);
+}
// converts an f32 to an f64 if necessary
Expression* ensureDouble(Expression* expr, MixedArena& allocator);