This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Main { | |
private static double factorial(int n) { | |
double result = 1; | |
for (int i = 1; i <= n; i++) { | |
result *= i; | |
} | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WebAssembly.instantiateStreaming = (r, i) => r.arrayBuffer().then(b => WebAssembly.instantiate(b, i)); | |
const _initWasm = WebAssembly.instantiate; | |
WebAssembly.instantiate = (wasm, imports) => { | |
const loader = {raw: new Uint8Array(new Uint8Array(wasm)), buffer: new Uint8Array(wasm), imports}; | |
_initWasm(loader.buffer, loader.imports).then(results => { | |
console.log(results); | |
const memory = Object.values(results.instance.exports).find(e => e instanceof WebAssembly.Memory); | |
window.HEAPF32 = new Float32Array(memory.buffer); | |
}); | |
return _initWasm(wasm, imports); |