rework assert, wasm_alert, wasm_clear, expect
This commit is contained in:
@@ -104,6 +104,9 @@ const mem = new memory_t(new WebAssembly['Memory']({ initial: 2000, maximum: 655
|
||||
ctx2d.fillStyle = `rgba(${r}, ${g}, ${b}, ${a})`;
|
||||
ctx2d.fill();
|
||||
},
|
||||
wasm_clear: () => {
|
||||
ctx2d.clearRect(0, 0, canvas.width, canvas.height);
|
||||
},
|
||||
wasm_set_clip: (x, y, w, h) => {
|
||||
ctx2d.restore();
|
||||
ctx2d.save();
|
||||
@@ -115,6 +118,11 @@ const mem = new memory_t(new WebAssembly['Memory']({ initial: 2000, maximum: 655
|
||||
return parseFloat(mem.read_cstr(str, len));
|
||||
},
|
||||
wasm_trap: () => { throw new Error() },
|
||||
wasm_alert: (str, len) => {
|
||||
const string = mem.read_cstr(str,len);
|
||||
console.log(string);
|
||||
alert(string);
|
||||
},
|
||||
};
|
||||
|
||||
const program = await WebAssembly['instantiate'](binary, { "env": wasm_imports });
|
||||
|
||||
Reference in New Issue
Block a user