@raviqqe/stak 0.12.34 → 0.12.36

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/run.js ADDED
@@ -0,0 +1,244 @@
1
+ let wasm;
2
+
3
+ let cachedUint8ArrayMemory0 = null;
4
+
5
+ function getUint8ArrayMemory0() {
6
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
7
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
8
+ }
9
+ return cachedUint8ArrayMemory0;
10
+ }
11
+
12
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
+
14
+ cachedTextDecoder.decode();
15
+
16
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
+ let numBytesDecoded = 0;
18
+ function decodeText(ptr, len) {
19
+ numBytesDecoded += len;
20
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
+ cachedTextDecoder.decode();
23
+ numBytesDecoded = len;
24
+ }
25
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
+ }
27
+
28
+ function getStringFromWasm0(ptr, len) {
29
+ ptr = ptr >>> 0;
30
+ return decodeText(ptr, len);
31
+ }
32
+
33
+ let WASM_VECTOR_LEN = 0;
34
+
35
+ const cachedTextEncoder = new TextEncoder();
36
+
37
+ if (!('encodeInto' in cachedTextEncoder)) {
38
+ cachedTextEncoder.encodeInto = function (arg, view) {
39
+ const buf = cachedTextEncoder.encode(arg);
40
+ view.set(buf);
41
+ return {
42
+ read: arg.length,
43
+ written: buf.length
44
+ };
45
+ }
46
+ }
47
+
48
+ function passStringToWasm0(arg, malloc, realloc) {
49
+
50
+ if (realloc === undefined) {
51
+ const buf = cachedTextEncoder.encode(arg);
52
+ const ptr = malloc(buf.length, 1) >>> 0;
53
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
54
+ WASM_VECTOR_LEN = buf.length;
55
+ return ptr;
56
+ }
57
+
58
+ let len = arg.length;
59
+ let ptr = malloc(len, 1) >>> 0;
60
+
61
+ const mem = getUint8ArrayMemory0();
62
+
63
+ let offset = 0;
64
+
65
+ for (; offset < len; offset++) {
66
+ const code = arg.charCodeAt(offset);
67
+ if (code > 0x7F) break;
68
+ mem[ptr + offset] = code;
69
+ }
70
+
71
+ if (offset !== len) {
72
+ if (offset !== 0) {
73
+ arg = arg.slice(offset);
74
+ }
75
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
76
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
77
+ const ret = cachedTextEncoder.encodeInto(arg, view);
78
+
79
+ offset += ret.written;
80
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
81
+ }
82
+
83
+ WASM_VECTOR_LEN = offset;
84
+ return ptr;
85
+ }
86
+
87
+ function passArray8ToWasm0(arg, malloc) {
88
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
89
+ getUint8ArrayMemory0().set(arg, ptr / 1);
90
+ WASM_VECTOR_LEN = arg.length;
91
+ return ptr;
92
+ }
93
+
94
+ function takeFromExternrefTable0(idx) {
95
+ const value = wasm.__wbindgen_externrefs.get(idx);
96
+ wasm.__externref_table_dealloc(idx);
97
+ return value;
98
+ }
99
+
100
+ function getArrayU8FromWasm0(ptr, len) {
101
+ ptr = ptr >>> 0;
102
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
103
+ }
104
+ /**
105
+ * Runs a Scheme script with standard input and returns its standard output.
106
+ * @param {string} source
107
+ * @param {Uint8Array} input
108
+ * @param {number} heap_size
109
+ * @returns {Uint8Array}
110
+ */
111
+ export function run(source, input, heap_size) {
112
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
113
+ const len0 = WASM_VECTOR_LEN;
114
+ const ptr1 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
115
+ const len1 = WASM_VECTOR_LEN;
116
+ const ret = wasm.run(ptr0, len0, ptr1, len1, heap_size);
117
+ if (ret[3]) {
118
+ throw takeFromExternrefTable0(ret[2]);
119
+ }
120
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
121
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
122
+ return v3;
123
+ }
124
+
125
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
126
+
127
+ async function __wbg_load(module, imports) {
128
+ if (typeof Response === 'function' && module instanceof Response) {
129
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
130
+ try {
131
+ return await WebAssembly.instantiateStreaming(module, imports);
132
+
133
+ } catch (e) {
134
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
135
+
136
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
137
+ 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);
138
+
139
+ } else {
140
+ throw e;
141
+ }
142
+ }
143
+ }
144
+
145
+ const bytes = await module.arrayBuffer();
146
+ return await WebAssembly.instantiate(bytes, imports);
147
+
148
+ } else {
149
+ const instance = await WebAssembly.instantiate(module, imports);
150
+
151
+ if (instance instanceof WebAssembly.Instance) {
152
+ return { instance, module };
153
+
154
+ } else {
155
+ return instance;
156
+ }
157
+ }
158
+ }
159
+
160
+ function __wbg_get_imports() {
161
+ const imports = {};
162
+ imports.wbg = {};
163
+ imports.wbg.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) {
164
+ const ret = Error(getStringFromWasm0(arg0, arg1));
165
+ return ret;
166
+ };
167
+ imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
168
+ throw new Error(getStringFromWasm0(arg0, arg1));
169
+ };
170
+ imports.wbg.__wbindgen_init_externref_table = function() {
171
+ const table = wasm.__wbindgen_externrefs;
172
+ const offset = table.grow(4);
173
+ table.set(0, undefined);
174
+ table.set(offset + 0, undefined);
175
+ table.set(offset + 1, null);
176
+ table.set(offset + 2, true);
177
+ table.set(offset + 3, false);
178
+ ;
179
+ };
180
+
181
+ return imports;
182
+ }
183
+
184
+ function __wbg_finalize_init(instance, module) {
185
+ wasm = instance.exports;
186
+ __wbg_init.__wbindgen_wasm_module = module;
187
+ cachedUint8ArrayMemory0 = null;
188
+
189
+
190
+ wasm.__wbindgen_start();
191
+ return wasm;
192
+ }
193
+
194
+ function initSync(module) {
195
+ if (wasm !== undefined) return wasm;
196
+
197
+
198
+ if (typeof module !== 'undefined') {
199
+ if (Object.getPrototypeOf(module) === Object.prototype) {
200
+ ({module} = module)
201
+ } else {
202
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
203
+ }
204
+ }
205
+
206
+ const imports = __wbg_get_imports();
207
+
208
+ if (!(module instanceof WebAssembly.Module)) {
209
+ module = new WebAssembly.Module(module);
210
+ }
211
+
212
+ const instance = new WebAssembly.Instance(module, imports);
213
+
214
+ return __wbg_finalize_init(instance, module);
215
+ }
216
+
217
+ async function __wbg_init(module_or_path) {
218
+ if (wasm !== undefined) return wasm;
219
+
220
+
221
+ if (typeof module_or_path !== 'undefined') {
222
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
223
+ ({module_or_path} = module_or_path)
224
+ } else {
225
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
226
+ }
227
+ }
228
+
229
+ if (typeof module_or_path === 'undefined') {
230
+ module_or_path = new URL('run_bg.wasm', import.meta.url);
231
+ }
232
+ const imports = __wbg_get_imports();
233
+
234
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
235
+ module_or_path = fetch(module_or_path);
236
+ }
237
+
238
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
239
+
240
+ return __wbg_finalize_init(instance, module);
241
+ }
242
+
243
+ export { initSync };
244
+ export default __wbg_init;
package/run_bg.wasm ADDED
Binary file
package/stak_wasm.d.ts CHANGED
@@ -1,13 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * Compiles source codes in Scheme.
5
- */
6
- export function compile(source: string): Uint8Array;
7
- /**
8
- * Interprets bytecode with standard input and returns its standard output.
9
- */
10
- export function interpret(bytecode: Uint8Array, input: Uint8Array, heap_size: number): Uint8Array;
11
3
  /**
12
4
  * Runs a Scheme script with standard input and returns its standard output.
13
5
  */
@@ -16,6 +8,14 @@ export function run(source: string, input: Uint8Array, heap_size: number): Uint8
16
8
  * Runs a REPL interpreter.
17
9
  */
18
10
  export function repl(heap_size: number): Promise<void>;
11
+ /**
12
+ * Compiles source codes in Scheme.
13
+ */
14
+ export function compile(source: string): Uint8Array;
15
+ /**
16
+ * Interprets bytecode with standard input and returns its standard output.
17
+ */
18
+ export function interpret(bytecode: Uint8Array, input: Uint8Array, heap_size: number): Uint8Array;
19
19
 
20
20
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
21
21
 
@@ -25,9 +25,9 @@ export interface InitOutput {
25
25
  readonly interpret: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
26
26
  readonly repl: (a: number) => any;
27
27
  readonly run: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
28
- readonly wasm_bindgen_2488234c93bbb349___convert__closures_____invoke___wasm_bindgen_2488234c93bbb349___JsValue_____: (a: number, b: number, c: any) => void;
29
- readonly wasm_bindgen_2488234c93bbb349___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__FnMut__wasm_bindgen_2488234c93bbb349___JsValue____Output_______: (a: number, b: number) => void;
30
- readonly wasm_bindgen_2488234c93bbb349___convert__closures_____invoke___wasm_bindgen_2488234c93bbb349___JsValue__wasm_bindgen_2488234c93bbb349___JsValue_____: (a: number, b: number, c: any, d: any) => void;
28
+ readonly wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue_____: (a: number, b: number, c: any) => void;
29
+ readonly wasm_bindgen_a10390bb34bad561___closure__destroy___dyn_core_6a51abefd5362b2___ops__function__FnMut__wasm_bindgen_a10390bb34bad561___JsValue____Output_______: (a: number, b: number) => void;
30
+ readonly wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue__wasm_bindgen_a10390bb34bad561___JsValue_____: (a: number, b: number, c: any, d: any) => void;
31
31
  readonly __wbindgen_malloc: (a: number, b: number) => number;
32
32
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
33
33
  readonly __wbindgen_exn_store: (a: number) => void;
package/stak_wasm.js CHANGED
@@ -209,6 +209,13 @@ function makeMutClosure(arg0, arg1, dtor, f) {
209
209
  return real;
210
210
  }
211
211
 
212
+ function passArray8ToWasm0(arg, malloc) {
213
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
214
+ getUint8ArrayMemory0().set(arg, ptr / 1);
215
+ WASM_VECTOR_LEN = arg.length;
216
+ return ptr;
217
+ }
218
+
212
219
  function takeFromExternrefTable0(idx) {
213
220
  const value = wasm.__wbindgen_externrefs.get(idx);
214
221
  wasm.__externref_table_dealloc(idx);
@@ -220,62 +227,66 @@ function getArrayU8FromWasm0(ptr, len) {
220
227
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
221
228
  }
222
229
  /**
223
- * Compiles source codes in Scheme.
230
+ * Runs a Scheme script with standard input and returns its standard output.
224
231
  * @param {string} source
232
+ * @param {Uint8Array} input
233
+ * @param {number} heap_size
225
234
  * @returns {Uint8Array}
226
235
  */
227
- export function compile(source) {
236
+ export function run(source, input, heap_size) {
228
237
  const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
229
238
  const len0 = WASM_VECTOR_LEN;
230
- const ret = wasm.compile(ptr0, len0);
239
+ const ptr1 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
240
+ const len1 = WASM_VECTOR_LEN;
241
+ const ret = wasm.run(ptr0, len0, ptr1, len1, heap_size);
231
242
  if (ret[3]) {
232
243
  throw takeFromExternrefTable0(ret[2]);
233
244
  }
234
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
245
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
235
246
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
236
- return v2;
247
+ return v3;
237
248
  }
238
249
 
239
- function passArray8ToWasm0(arg, malloc) {
240
- const ptr = malloc(arg.length * 1, 1) >>> 0;
241
- getUint8ArrayMemory0().set(arg, ptr / 1);
242
- WASM_VECTOR_LEN = arg.length;
243
- return ptr;
244
- }
245
250
  /**
246
- * Interprets bytecode with standard input and returns its standard output.
247
- * @param {Uint8Array} bytecode
248
- * @param {Uint8Array} input
251
+ * Runs a REPL interpreter.
249
252
  * @param {number} heap_size
253
+ * @returns {Promise<void>}
254
+ */
255
+ export function repl(heap_size) {
256
+ const ret = wasm.repl(heap_size);
257
+ return ret;
258
+ }
259
+
260
+ /**
261
+ * Compiles source codes in Scheme.
262
+ * @param {string} source
250
263
  * @returns {Uint8Array}
251
264
  */
252
- export function interpret(bytecode, input, heap_size) {
253
- const ptr0 = passArray8ToWasm0(bytecode, wasm.__wbindgen_malloc);
265
+ export function compile(source) {
266
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
254
267
  const len0 = WASM_VECTOR_LEN;
255
- const ptr1 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
256
- const len1 = WASM_VECTOR_LEN;
257
- const ret = wasm.interpret(ptr0, len0, ptr1, len1, heap_size);
268
+ const ret = wasm.compile(ptr0, len0);
258
269
  if (ret[3]) {
259
270
  throw takeFromExternrefTable0(ret[2]);
260
271
  }
261
- var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
272
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
262
273
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
263
- return v3;
274
+ return v2;
264
275
  }
265
276
 
266
277
  /**
267
- * Runs a Scheme script with standard input and returns its standard output.
268
- * @param {string} source
278
+ * Interprets bytecode with standard input and returns its standard output.
279
+ * @param {Uint8Array} bytecode
269
280
  * @param {Uint8Array} input
270
281
  * @param {number} heap_size
271
282
  * @returns {Uint8Array}
272
283
  */
273
- export function run(source, input, heap_size) {
274
- const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
284
+ export function interpret(bytecode, input, heap_size) {
285
+ const ptr0 = passArray8ToWasm0(bytecode, wasm.__wbindgen_malloc);
275
286
  const len0 = WASM_VECTOR_LEN;
276
287
  const ptr1 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
277
288
  const len1 = WASM_VECTOR_LEN;
278
- const ret = wasm.run(ptr0, len0, ptr1, len1, heap_size);
289
+ const ret = wasm.interpret(ptr0, len0, ptr1, len1, heap_size);
279
290
  if (ret[3]) {
280
291
  throw takeFromExternrefTable0(ret[2]);
281
292
  }
@@ -284,22 +295,12 @@ export function run(source, input, heap_size) {
284
295
  return v3;
285
296
  }
286
297
 
287
- /**
288
- * Runs a REPL interpreter.
289
- * @param {number} heap_size
290
- * @returns {Promise<void>}
291
- */
292
- export function repl(heap_size) {
293
- const ret = wasm.repl(heap_size);
294
- return ret;
295
- }
296
-
297
- function wasm_bindgen_2488234c93bbb349___convert__closures_____invoke___wasm_bindgen_2488234c93bbb349___JsValue_____(arg0, arg1, arg2) {
298
- wasm.wasm_bindgen_2488234c93bbb349___convert__closures_____invoke___wasm_bindgen_2488234c93bbb349___JsValue_____(arg0, arg1, arg2);
298
+ function wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue_____(arg0, arg1, arg2) {
299
+ wasm.wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue_____(arg0, arg1, arg2);
299
300
  }
300
301
 
301
- function wasm_bindgen_2488234c93bbb349___convert__closures_____invoke___wasm_bindgen_2488234c93bbb349___JsValue__wasm_bindgen_2488234c93bbb349___JsValue_____(arg0, arg1, arg2, arg3) {
302
- wasm.wasm_bindgen_2488234c93bbb349___convert__closures_____invoke___wasm_bindgen_2488234c93bbb349___JsValue__wasm_bindgen_2488234c93bbb349___JsValue_____(arg0, arg1, arg2, arg3);
302
+ function wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue__wasm_bindgen_a10390bb34bad561___JsValue_____(arg0, arg1, arg2, arg3) {
303
+ wasm.wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue__wasm_bindgen_a10390bb34bad561___JsValue_____(arg0, arg1, arg2, arg3);
303
304
  }
304
305
 
305
306
  const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
@@ -390,7 +391,7 @@ function __wbg_get_imports() {
390
391
  const a = state0.a;
391
392
  state0.a = 0;
392
393
  try {
393
- return wasm_bindgen_2488234c93bbb349___convert__closures_____invoke___wasm_bindgen_2488234c93bbb349___JsValue__wasm_bindgen_2488234c93bbb349___JsValue_____(a, state0.b, arg0, arg1);
394
+ return wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue__wasm_bindgen_a10390bb34bad561___JsValue_____(a, state0.b, arg0, arg1);
394
395
  } finally {
395
396
  state0.a = a;
396
397
  }
@@ -412,7 +413,7 @@ function __wbg_get_imports() {
412
413
  imports.wbg.__wbg_queueMicrotask_9d76cacb20c84d58 = function(arg0) {
413
414
  queueMicrotask(arg0);
414
415
  };
415
- imports.wbg.__wbg_read_stdin_7b63e62e0e47e337 = function() {
416
+ imports.wbg.__wbg_read_stdin_77080b6e84e0757b = function() {
416
417
  const ret = read_stdin();
417
418
  return ret;
418
419
  };
@@ -444,17 +445,17 @@ function __wbg_get_imports() {
444
445
  const ret = arg0.then(arg1, arg2);
445
446
  return ret;
446
447
  };
447
- imports.wbg.__wbg_write_stderr_802f547b5e944724 = function(arg0) {
448
+ imports.wbg.__wbg_write_stderr_f819f461d9858a57 = function(arg0) {
448
449
  const ret = write_stderr(arg0);
449
450
  return ret;
450
451
  };
451
- imports.wbg.__wbg_write_stdout_e732016c3415b67b = function(arg0) {
452
+ imports.wbg.__wbg_write_stdout_0d33dd5f146c1bb9 = function(arg0) {
452
453
  const ret = write_stdout(arg0);
453
454
  return ret;
454
455
  };
455
456
  imports.wbg.__wbindgen_cast_80e5451c6d1fd870 = function(arg0, arg1) {
456
457
  // Cast intrinsic for `Closure(Closure { dtor_idx: 17, function: Function { arguments: [Externref], shim_idx: 18, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
457
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_2488234c93bbb349___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__FnMut__wasm_bindgen_2488234c93bbb349___JsValue____Output_______, wasm_bindgen_2488234c93bbb349___convert__closures_____invoke___wasm_bindgen_2488234c93bbb349___JsValue_____);
458
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_a10390bb34bad561___closure__destroy___dyn_core_6a51abefd5362b2___ops__function__FnMut__wasm_bindgen_a10390bb34bad561___JsValue____Output_______, wasm_bindgen_a10390bb34bad561___convert__closures_____invoke___wasm_bindgen_a10390bb34bad561___JsValue_____);
458
459
  return ret;
459
460
  };
460
461
  imports.wbg.__wbindgen_init_externref_table = function() {
package/stak_wasm_bg.wasm CHANGED
Binary file