@raviqqe/stak 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -5
- package/stak_wasm.d.ts +34 -1
- package/stak_wasm.js +271 -4
- package/stak_wasm_bg.wasm +0 -0
- package/stak_wasm_bg.js +0 -191
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raviqqe/stak",
|
|
3
|
-
"private": false,
|
|
4
3
|
"description": "Stak Scheme VM in WebAssembly",
|
|
5
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
6
5
|
"license": "SEE LICENSE IN ../LICENSE",
|
|
7
6
|
"repository": {
|
|
8
7
|
"type": "git",
|
|
@@ -11,11 +10,19 @@
|
|
|
11
10
|
"files": [
|
|
12
11
|
"stak_wasm_bg.wasm",
|
|
13
12
|
"stak_wasm.js",
|
|
14
|
-
"stak_wasm_bg.js",
|
|
15
13
|
"stak_wasm.d.ts"
|
|
16
14
|
],
|
|
17
15
|
"module": "stak_wasm.js",
|
|
18
16
|
"types": "stak_wasm.d.ts",
|
|
19
|
-
"sideEffects": [
|
|
20
|
-
|
|
17
|
+
"sideEffects": [
|
|
18
|
+
"./snippets/*"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"interpreter",
|
|
22
|
+
"language",
|
|
23
|
+
"scheme"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"provenance": true
|
|
27
|
+
}
|
|
21
28
|
}
|
package/stak_wasm.d.ts
CHANGED
|
@@ -11,4 +11,37 @@ export function compile(source: string): Uint8Array;
|
|
|
11
11
|
* @param {number} heap_size
|
|
12
12
|
* @returns {Uint8Array}
|
|
13
13
|
*/
|
|
14
|
-
export function
|
|
14
|
+
export function interpret(bytecodes: Uint8Array, input: Uint8Array, heap_size: number): Uint8Array;
|
|
15
|
+
|
|
16
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
17
|
+
|
|
18
|
+
export interface InitOutput {
|
|
19
|
+
readonly memory: WebAssembly.Memory;
|
|
20
|
+
readonly compile: (a: number, b: number, c: number) => void;
|
|
21
|
+
readonly interpret: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
22
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
23
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
24
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
25
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
29
|
+
/**
|
|
30
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
31
|
+
* a precompiled `WebAssembly.Module`.
|
|
32
|
+
*
|
|
33
|
+
* @param {SyncInitInput} module
|
|
34
|
+
*
|
|
35
|
+
* @returns {InitOutput}
|
|
36
|
+
*/
|
|
37
|
+
export function initSync(module: SyncInitInput): InitOutput;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
41
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
42
|
+
*
|
|
43
|
+
* @param {InitInput | Promise<InitInput>} module_or_path
|
|
44
|
+
*
|
|
45
|
+
* @returns {Promise<InitOutput>}
|
|
46
|
+
*/
|
|
47
|
+
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/stak_wasm.js
CHANGED
|
@@ -1,4 +1,271 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
4
|
+
|
|
5
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
6
|
+
|
|
7
|
+
let cachedUint8Memory0 = null;
|
|
8
|
+
|
|
9
|
+
function getUint8Memory0() {
|
|
10
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
11
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
12
|
+
}
|
|
13
|
+
return cachedUint8Memory0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getStringFromWasm0(ptr, len) {
|
|
17
|
+
ptr = ptr >>> 0;
|
|
18
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const heap = new Array(128).fill(undefined);
|
|
22
|
+
|
|
23
|
+
heap.push(undefined, null, true, false);
|
|
24
|
+
|
|
25
|
+
let heap_next = heap.length;
|
|
26
|
+
|
|
27
|
+
function addHeapObject(obj) {
|
|
28
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
29
|
+
const idx = heap_next;
|
|
30
|
+
heap_next = heap[idx];
|
|
31
|
+
|
|
32
|
+
heap[idx] = obj;
|
|
33
|
+
return idx;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let WASM_VECTOR_LEN = 0;
|
|
37
|
+
|
|
38
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
39
|
+
|
|
40
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
41
|
+
? function (arg, view) {
|
|
42
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
43
|
+
}
|
|
44
|
+
: function (arg, view) {
|
|
45
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
46
|
+
view.set(buf);
|
|
47
|
+
return {
|
|
48
|
+
read: arg.length,
|
|
49
|
+
written: buf.length
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
54
|
+
|
|
55
|
+
if (realloc === undefined) {
|
|
56
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
57
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
58
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
59
|
+
WASM_VECTOR_LEN = buf.length;
|
|
60
|
+
return ptr;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let len = arg.length;
|
|
64
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
65
|
+
|
|
66
|
+
const mem = getUint8Memory0();
|
|
67
|
+
|
|
68
|
+
let offset = 0;
|
|
69
|
+
|
|
70
|
+
for (; offset < len; offset++) {
|
|
71
|
+
const code = arg.charCodeAt(offset);
|
|
72
|
+
if (code > 0x7F) break;
|
|
73
|
+
mem[ptr + offset] = code;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (offset !== len) {
|
|
77
|
+
if (offset !== 0) {
|
|
78
|
+
arg = arg.slice(offset);
|
|
79
|
+
}
|
|
80
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
81
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
82
|
+
const ret = encodeString(arg, view);
|
|
83
|
+
|
|
84
|
+
offset += ret.written;
|
|
85
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
WASM_VECTOR_LEN = offset;
|
|
89
|
+
return ptr;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let cachedInt32Memory0 = null;
|
|
93
|
+
|
|
94
|
+
function getInt32Memory0() {
|
|
95
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
96
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
97
|
+
}
|
|
98
|
+
return cachedInt32Memory0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function getObject(idx) { return heap[idx]; }
|
|
102
|
+
|
|
103
|
+
function dropObject(idx) {
|
|
104
|
+
if (idx < 132) return;
|
|
105
|
+
heap[idx] = heap_next;
|
|
106
|
+
heap_next = idx;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function takeObject(idx) {
|
|
110
|
+
const ret = getObject(idx);
|
|
111
|
+
dropObject(idx);
|
|
112
|
+
return ret;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
116
|
+
ptr = ptr >>> 0;
|
|
117
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @param {string} source
|
|
121
|
+
* @returns {Uint8Array}
|
|
122
|
+
*/
|
|
123
|
+
export function compile(source) {
|
|
124
|
+
try {
|
|
125
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
126
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
127
|
+
const len0 = WASM_VECTOR_LEN;
|
|
128
|
+
wasm.compile(retptr, ptr0, len0);
|
|
129
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
130
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
131
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
132
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
133
|
+
if (r3) {
|
|
134
|
+
throw takeObject(r2);
|
|
135
|
+
}
|
|
136
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
137
|
+
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
138
|
+
return v2;
|
|
139
|
+
} finally {
|
|
140
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
145
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
146
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
147
|
+
WASM_VECTOR_LEN = arg.length;
|
|
148
|
+
return ptr;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* @param {Uint8Array} bytecodes
|
|
152
|
+
* @param {Uint8Array} input
|
|
153
|
+
* @param {number} heap_size
|
|
154
|
+
* @returns {Uint8Array}
|
|
155
|
+
*/
|
|
156
|
+
export function interpret(bytecodes, input, heap_size) {
|
|
157
|
+
try {
|
|
158
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
159
|
+
const ptr0 = passArray8ToWasm0(bytecodes, wasm.__wbindgen_malloc);
|
|
160
|
+
const len0 = WASM_VECTOR_LEN;
|
|
161
|
+
const ptr1 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
162
|
+
const len1 = WASM_VECTOR_LEN;
|
|
163
|
+
wasm.interpret(retptr, ptr0, len0, ptr1, len1, heap_size);
|
|
164
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
165
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
166
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
167
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
168
|
+
if (r3) {
|
|
169
|
+
throw takeObject(r2);
|
|
170
|
+
}
|
|
171
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
172
|
+
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
173
|
+
return v3;
|
|
174
|
+
} finally {
|
|
175
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async function __wbg_load(module, imports) {
|
|
180
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
181
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
182
|
+
try {
|
|
183
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
184
|
+
|
|
185
|
+
} catch (e) {
|
|
186
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
187
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
188
|
+
|
|
189
|
+
} else {
|
|
190
|
+
throw e;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const bytes = await module.arrayBuffer();
|
|
196
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
197
|
+
|
|
198
|
+
} else {
|
|
199
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
200
|
+
|
|
201
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
202
|
+
return { instance, module };
|
|
203
|
+
|
|
204
|
+
} else {
|
|
205
|
+
return instance;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function __wbg_get_imports() {
|
|
211
|
+
const imports = {};
|
|
212
|
+
imports.wbg = {};
|
|
213
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
214
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
215
|
+
return addHeapObject(ret);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
return imports;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function __wbg_init_memory(imports, maybe_memory) {
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function __wbg_finalize_init(instance, module) {
|
|
226
|
+
wasm = instance.exports;
|
|
227
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
228
|
+
cachedInt32Memory0 = null;
|
|
229
|
+
cachedUint8Memory0 = null;
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
return wasm;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function initSync(module) {
|
|
236
|
+
if (wasm !== undefined) return wasm;
|
|
237
|
+
|
|
238
|
+
const imports = __wbg_get_imports();
|
|
239
|
+
|
|
240
|
+
__wbg_init_memory(imports);
|
|
241
|
+
|
|
242
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
243
|
+
module = new WebAssembly.Module(module);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
247
|
+
|
|
248
|
+
return __wbg_finalize_init(instance, module);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async function __wbg_init(input) {
|
|
252
|
+
if (wasm !== undefined) return wasm;
|
|
253
|
+
|
|
254
|
+
if (typeof input === 'undefined') {
|
|
255
|
+
input = new URL('stak_wasm_bg.wasm', import.meta.url);
|
|
256
|
+
}
|
|
257
|
+
const imports = __wbg_get_imports();
|
|
258
|
+
|
|
259
|
+
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
|
260
|
+
input = fetch(input);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
__wbg_init_memory(imports);
|
|
264
|
+
|
|
265
|
+
const { instance, module } = await __wbg_load(await input, imports);
|
|
266
|
+
|
|
267
|
+
return __wbg_finalize_init(instance, module);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export { initSync }
|
|
271
|
+
export default __wbg_init;
|
package/stak_wasm_bg.wasm
CHANGED
|
Binary file
|
package/stak_wasm_bg.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
let wasm;
|
|
2
|
-
export function __wbg_set_wasm(val) {
|
|
3
|
-
wasm = val;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
8
|
-
|
|
9
|
-
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
10
|
-
|
|
11
|
-
cachedTextDecoder.decode();
|
|
12
|
-
|
|
13
|
-
let cachedUint8Memory0 = null;
|
|
14
|
-
|
|
15
|
-
function getUint8Memory0() {
|
|
16
|
-
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
17
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
18
|
-
}
|
|
19
|
-
return cachedUint8Memory0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function getStringFromWasm0(ptr, len) {
|
|
23
|
-
ptr = ptr >>> 0;
|
|
24
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const heap = new Array(128).fill(undefined);
|
|
28
|
-
|
|
29
|
-
heap.push(undefined, null, true, false);
|
|
30
|
-
|
|
31
|
-
let heap_next = heap.length;
|
|
32
|
-
|
|
33
|
-
function addHeapObject(obj) {
|
|
34
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
35
|
-
const idx = heap_next;
|
|
36
|
-
heap_next = heap[idx];
|
|
37
|
-
|
|
38
|
-
heap[idx] = obj;
|
|
39
|
-
return idx;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
let WASM_VECTOR_LEN = 0;
|
|
43
|
-
|
|
44
|
-
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
45
|
-
|
|
46
|
-
let cachedTextEncoder = new lTextEncoder('utf-8');
|
|
47
|
-
|
|
48
|
-
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
49
|
-
? function (arg, view) {
|
|
50
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
51
|
-
}
|
|
52
|
-
: function (arg, view) {
|
|
53
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
54
|
-
view.set(buf);
|
|
55
|
-
return {
|
|
56
|
-
read: arg.length,
|
|
57
|
-
written: buf.length
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
62
|
-
|
|
63
|
-
if (realloc === undefined) {
|
|
64
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
65
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
66
|
-
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
67
|
-
WASM_VECTOR_LEN = buf.length;
|
|
68
|
-
return ptr;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
let len = arg.length;
|
|
72
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
73
|
-
|
|
74
|
-
const mem = getUint8Memory0();
|
|
75
|
-
|
|
76
|
-
let offset = 0;
|
|
77
|
-
|
|
78
|
-
for (; offset < len; offset++) {
|
|
79
|
-
const code = arg.charCodeAt(offset);
|
|
80
|
-
if (code > 0x7F) break;
|
|
81
|
-
mem[ptr + offset] = code;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (offset !== len) {
|
|
85
|
-
if (offset !== 0) {
|
|
86
|
-
arg = arg.slice(offset);
|
|
87
|
-
}
|
|
88
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
89
|
-
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
90
|
-
const ret = encodeString(arg, view);
|
|
91
|
-
|
|
92
|
-
offset += ret.written;
|
|
93
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
WASM_VECTOR_LEN = offset;
|
|
97
|
-
return ptr;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
let cachedInt32Memory0 = null;
|
|
101
|
-
|
|
102
|
-
function getInt32Memory0() {
|
|
103
|
-
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
104
|
-
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
105
|
-
}
|
|
106
|
-
return cachedInt32Memory0;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function getObject(idx) { return heap[idx]; }
|
|
110
|
-
|
|
111
|
-
function dropObject(idx) {
|
|
112
|
-
if (idx < 132) return;
|
|
113
|
-
heap[idx] = heap_next;
|
|
114
|
-
heap_next = idx;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function takeObject(idx) {
|
|
118
|
-
const ret = getObject(idx);
|
|
119
|
-
dropObject(idx);
|
|
120
|
-
return ret;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
124
|
-
ptr = ptr >>> 0;
|
|
125
|
-
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* @param {string} source
|
|
129
|
-
* @returns {Uint8Array}
|
|
130
|
-
*/
|
|
131
|
-
export function compile(source) {
|
|
132
|
-
try {
|
|
133
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
134
|
-
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
135
|
-
const len0 = WASM_VECTOR_LEN;
|
|
136
|
-
wasm.compile(retptr, ptr0, len0);
|
|
137
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
138
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
139
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
140
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
141
|
-
if (r3) {
|
|
142
|
-
throw takeObject(r2);
|
|
143
|
-
}
|
|
144
|
-
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
145
|
-
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
146
|
-
return v2;
|
|
147
|
-
} finally {
|
|
148
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
153
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
154
|
-
getUint8Memory0().set(arg, ptr / 1);
|
|
155
|
-
WASM_VECTOR_LEN = arg.length;
|
|
156
|
-
return ptr;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* @param {Uint8Array} bytecodes
|
|
160
|
-
* @param {Uint8Array} input
|
|
161
|
-
* @param {number} heap_size
|
|
162
|
-
* @returns {Uint8Array}
|
|
163
|
-
*/
|
|
164
|
-
export function run(bytecodes, input, heap_size) {
|
|
165
|
-
try {
|
|
166
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
167
|
-
const ptr0 = passArray8ToWasm0(bytecodes, wasm.__wbindgen_malloc);
|
|
168
|
-
const len0 = WASM_VECTOR_LEN;
|
|
169
|
-
const ptr1 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
|
|
170
|
-
const len1 = WASM_VECTOR_LEN;
|
|
171
|
-
wasm.run(retptr, ptr0, len0, ptr1, len1, heap_size);
|
|
172
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
173
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
174
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
175
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
176
|
-
if (r3) {
|
|
177
|
-
throw takeObject(r2);
|
|
178
|
-
}
|
|
179
|
-
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
180
|
-
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
181
|
-
return v3;
|
|
182
|
-
} finally {
|
|
183
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export function __wbindgen_error_new(arg0, arg1) {
|
|
188
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
189
|
-
return addHeapObject(ret);
|
|
190
|
-
};
|
|
191
|
-
|