blob: 649e48a00b6bededa5f1e6436bd6bc267a0a01fe [file] [log] [blame]
load("../libwabt.js");
export function compile(wat, options = {}) {
// we need a filename for whatever reason...
let parseResult = WabtModule().parseWat("filenamesAreCool", wat, options);
let binaryResult = parseResult.toBinary(options);
if (options.log) {
print("log for compilation:");
print(binaryResult.log);
}
return new WebAssembly.Module(binaryResult.buffer);
}
export function instantiate(wat, imports = {}, options = {}) {
return new WebAssembly.Instance(compile(wat, options), imports);
}