#include "asm_v_wasm.h"
#include "support/utilities.h"
#include "wasm.h"
namespace wasm {
JsType wasmToJsType(Type type) {
TODO_SINGLE_COMPOUND(type);
switch (type.getBasic()) {
case Type::i32:
return JS_INT;
case Type::f32:
return JS_FLOAT;
case Type::f64:
return JS_DOUBLE;
case Type::i64:
return JS_INT64;
case Type::v128:
WASM_UNREACHABLE("v128 not implemented yet");
case Type::none:
return JS_NONE;
case Type::unreachable:
WASM_UNREACHABLE("invalid type");
}
WASM_UNREACHABLE("invalid type");
}
char getSig(Type type) {
TODO_SINGLE_COMPOUND(type);
switch (type.getBasic()) {
case Type::i32:
return 'i';
case Type::i64:
return 'j';
case Type::f32:
return 'f';
case Type::f64:
return 'd';
case Type::v128:
return 'V';
case Type::none:
return 'v';
case Type::unreachable:
WASM_UNREACHABLE("invalid type");
}
WASM_UNREACHABLE("invalid type");
}
std::string getSig(Type results, Type params) {
assert(!results.isTuple());
std::string sig;
sig += getSig(results);
for (const auto& param : params) {
sig += getSig(param);
}
return sig;
}
}