MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / instantiate

Function instantiate

test/js_optimizer/constructor.js:2–60  ·  view source on GitHub ↗
(wasmImports, wasmMemory, wasmTable)

Source from the content-addressed store, hash-verified

1// EMSCRIPTEN_START_ASM
2function instantiate(wasmImports, wasmMemory, wasmTable) {
3 var scratchBuffer = new ArrayBuffer(16);
4 var i32ScratchView = new Int32Array(scratchBuffer);
5 var f32ScratchView = new Float32Array(scratchBuffer);
6
7 function wasm2js_scratch_load_i32(index) {
8 return i32ScratchView[index];
9 }
10
11 function wasm2js_scratch_store_i32(index, value) {
12 i32ScratchView[index] = value;
13 }
14
15 function wasm2js_scratch_store_f32(value) {
16 f32ScratchView[2] = value;
17 }
18
19 function wasm2js_scratch_load_f32() {
20 return f32ScratchView[2];
21 }
22
23function asmFunc(global, env, buffer) {
24 var HEAP8 = new global.Int8Array(buffer);
25 var emscripten_glVertexAttrib4fv = env.emscripten_glVertexAttrib4fv;
26 var global$0 = 6191184;
27 // EMSCRIPTEN_START_FUNCS
28 function foo(x, y) {
29 return constructor(x + y);
30}
31 function constructor(foo) {
32 return foo + 1;
33}
34 function mainey() {
35 return foo(10, 20) + constructor(30);
36}
37 // EMSCRIPTEN_END_FUNCS
38 return {
39 "main": mainey
40 };
41}
42
43return asmFunc({
44 'Int8Array': Int8Array,
45 'Int16Array': Int16Array,
46 'Int32Array': Int32Array,
47 'Uint8Array': Uint8Array,
48 'Uint16Array': Uint16Array,
49 'Uint32Array': Uint32Array,
50 'Float32Array': Float32Array,
51 'Float64Array': Float64Array,
52 'NaN': NaN,
53 'Infinity': Infinity,
54 'Math': Math
55 },
56 wasmImports,
57 wasmMemory.buffer
58)
59
60}// EMSCRIPTEN_END_ASM

Callers

nothing calls this directly

Calls 1

asmFuncFunction · 0.70

Tested by

no test coverage detected