@wasmgroundup/emit 0.2.10 → 0.2.11

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/dist/index.d.ts CHANGED
@@ -21,6 +21,8 @@ declare function exportsec(exports: BytecodeFragment): BytecodeFragment;
21
21
  declare const funcidx: typeof u32;
22
22
  declare const exportdesc: {
23
23
  func(idx: number): BytecodeFragment;
24
+ table(idx: number): BytecodeFragment;
25
+ mem(idx: number): BytecodeFragment;
24
26
  global(idx: number): BytecodeFragment;
25
27
  };
26
28
  declare function module(sections: any): BytecodeFragment;
@@ -95,11 +97,29 @@ declare function importsec(ims: BytecodeFragment): BytecodeFragment;
95
97
  declare const importdesc: {
96
98
  func(x: number): BytecodeFragment;
97
99
  };
100
+ declare function mem(memtype: any): any;
101
+ declare function memsec(mems: BytecodeFragment[]): (number | BytecodeFragment)[];
102
+ declare const limits: {
103
+ min(n: number): (number | number[])[];
104
+ minmax(n: number, m: number): (number | number[])[];
105
+ };
98
106
  declare const mut: {
99
107
  const: number;
100
108
  var: number;
101
109
  };
102
110
  declare function globaltype(t: any, m: any): any[];
103
111
  declare function global(gt: any, e: any): any[];
104
- declare function globalsec(globs: any): (number | BytecodeFragment)[];
105
- export { blocktype, BytecodeFragment, code, codesec, export_, exportdesc, exportsec, f64, func, funcidx, funcsec, functype, global, globalsec, globaltype, i32, import_, importdesc, importsec, instr, locals, module, mut, name, section, typeidx, typesec, u32, valtype, vec, };
112
+ declare function globalsec(globs: BytecodeFragment[]): (number | BytecodeFragment)[];
113
+ declare function tabletype(elemtype: BytecodeFragment, limits: BytecodeFragment): BytecodeFragment[];
114
+ declare function table(tabletype: BytecodeFragment): BytecodeFragment;
115
+ declare function tablesec(tables: BytecodeFragment[]): (number | BytecodeFragment)[];
116
+ declare const elemtype: {
117
+ funcref: number;
118
+ };
119
+ declare const start: typeof u32;
120
+ declare function startsec(st: BytecodeFragment): (number | BytecodeFragment)[];
121
+ declare function data(x: BytecodeFragment, e: BytecodeFragment, bs: BytecodeFragment[]): BytecodeFragment[];
122
+ declare function datasec(segs: BytecodeFragment[]): (number | BytecodeFragment)[];
123
+ declare function elem(x: BytecodeFragment, e: BytecodeFragment, ys: BytecodeFragment[]): BytecodeFragment[];
124
+ declare function elemsec(segs: BytecodeFragment[]): (number | BytecodeFragment)[];
125
+ export { blocktype, BytecodeFragment, code, codesec, data, datasec, elem, elemsec, elemtype, export_, exportdesc, exportsec, f64, func, funcidx, funcsec, functype, global, globalsec, globaltype, i32, import_, importdesc, importsec, instr, limits, locals, mem, memsec, module, mut, name, section, start, startsec, table, tablesec, tabletype, typeidx, typesec, u32, valtype, vec, };
package/dist/index.js CHANGED
@@ -1,9 +1,14 @@
1
1
  const SECTION_ID_TYPE = 1;
2
2
  const SECTION_ID_IMPORT = 2;
3
3
  const SECTION_ID_FUNCTION = 3;
4
+ const SECTION_ID_TABLE = 4;
5
+ const SECTION_ID_MEMORY = 5;
4
6
  const SECTION_ID_GLOBAL = 6;
5
7
  const SECTION_ID_EXPORT = 7;
8
+ const SECTION_ID_START = 8;
9
+ const SECTION_ID_ELEMENT = 9;
6
10
  const SECTION_ID_CODE = 10;
11
+ const SECTION_ID_DATA = 11;
7
12
  const TYPE_FUNCTION = 0x60;
8
13
  function stringToBytes(s) {
9
14
  const bytes = new TextEncoder().encode(s);
@@ -78,6 +83,12 @@ const exportdesc = {
78
83
  func(idx) {
79
84
  return [0x00, funcidx(idx)];
80
85
  },
86
+ table(idx) {
87
+ return [0x01, tableidx(idx)];
88
+ },
89
+ mem(idx) {
90
+ return [0x02, memidx(idx)];
91
+ },
81
92
  global(idx) {
82
93
  return [0x03, globalidx(idx)];
83
94
  },
@@ -210,6 +221,21 @@ const importdesc = {
210
221
  return [0x00, typeidx(x)];
211
222
  },
212
223
  };
224
+ const memidx = u32;
225
+ function mem(memtype) {
226
+ return memtype;
227
+ }
228
+ function memsec(mems) {
229
+ return section(SECTION_ID_MEMORY, vec(mems));
230
+ }
231
+ const limits = {
232
+ min(n) {
233
+ return [0x00, u32(n)];
234
+ },
235
+ minmax(n, m) {
236
+ return [0x01, u32(n), u32(m)];
237
+ },
238
+ };
213
239
  const globalidx = u32;
214
240
  const mut = {
215
241
  const: 0x00,
@@ -227,4 +253,34 @@ function global(gt, e) {
227
253
  function globalsec(globs) {
228
254
  return section(SECTION_ID_GLOBAL, vec(globs));
229
255
  }
230
- export { blocktype, code, codesec, export_, exportdesc, exportsec, f64, func, funcidx, funcsec, functype, global, globalsec, globaltype, i32, import_, importdesc, importsec, instr, locals, module, mut, name, section, typeidx, typesec, u32, valtype, vec, };
256
+ function tabletype(elemtype, limits) {
257
+ return [elemtype, limits];
258
+ }
259
+ function table(tabletype) {
260
+ return tabletype;
261
+ }
262
+ function tablesec(tables) {
263
+ return section(SECTION_ID_TABLE, vec(tables));
264
+ }
265
+ const elemtype = { funcref: 0x70 };
266
+ const tableidx = u32;
267
+ const start = funcidx;
268
+ // st:start
269
+ function startsec(st) {
270
+ return section(SECTION_ID_START, st);
271
+ }
272
+ // x:memidx e:expr b∗:vec(byte)
273
+ function data(x, e, bs) {
274
+ return [x, e, vec(bs)];
275
+ }
276
+ function datasec(segs) {
277
+ return section(SECTION_ID_DATA, vec(segs));
278
+ }
279
+ // x:tableidx e:expr y∗:vec(funcidx)
280
+ function elem(x, e, ys) {
281
+ return [x, e, vec(ys)];
282
+ }
283
+ function elemsec(segs) {
284
+ return section(SECTION_ID_ELEMENT, vec(segs));
285
+ }
286
+ export { blocktype, code, codesec, data, datasec, elem, elemsec, elemtype, export_, exportdesc, exportsec, f64, func, funcidx, funcsec, functype, global, globalsec, globaltype, i32, import_, importdesc, importsec, instr, limits, locals, mem, memsec, module, mut, name, section, start, startsec, table, tablesec, tabletype, typeidx, typesec, u32, valtype, vec, };
package/index.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  const SECTION_ID_TYPE = 1;
2
2
  const SECTION_ID_IMPORT = 2;
3
3
  const SECTION_ID_FUNCTION = 3;
4
+ const SECTION_ID_TABLE = 4;
5
+ const SECTION_ID_MEMORY = 5;
4
6
  const SECTION_ID_GLOBAL = 6;
5
7
  const SECTION_ID_EXPORT = 7;
8
+ const SECTION_ID_START = 8;
9
+ const SECTION_ID_ELEMENT = 9;
6
10
  const SECTION_ID_CODE = 10;
11
+ const SECTION_ID_DATA = 11;
7
12
 
8
13
  const TYPE_FUNCTION = 0x60;
9
14
 
@@ -106,6 +111,12 @@ const exportdesc = {
106
111
  func(idx: number): BytecodeFragment {
107
112
  return [0x00, funcidx(idx)];
108
113
  },
114
+ table(idx: number): BytecodeFragment {
115
+ return [0x01, tableidx(idx)];
116
+ },
117
+ mem(idx: number): BytecodeFragment {
118
+ return [0x02, memidx(idx)];
119
+ },
109
120
  global(idx: number): BytecodeFragment {
110
121
  return [0x03, globalidx(idx)];
111
122
  },
@@ -258,6 +269,25 @@ const importdesc = {
258
269
  },
259
270
  };
260
271
 
272
+ const memidx = u32;
273
+
274
+ function mem(memtype) {
275
+ return memtype;
276
+ }
277
+
278
+ function memsec(mems: BytecodeFragment[]) {
279
+ return section(SECTION_ID_MEMORY, vec(mems));
280
+ }
281
+
282
+ const limits = {
283
+ min(n: number) {
284
+ return [0x00, u32(n)];
285
+ },
286
+ minmax(n: number, m: number) {
287
+ return [0x01, u32(n), u32(m)];
288
+ },
289
+ };
290
+
261
291
  const globalidx = u32;
262
292
 
263
293
  const mut = {
@@ -276,15 +306,69 @@ function global(gt, e) {
276
306
  }
277
307
 
278
308
  // glob*:vec(global)
279
- function globalsec(globs) {
309
+ function globalsec(globs: BytecodeFragment[]) {
280
310
  return section(SECTION_ID_GLOBAL, vec(globs));
281
311
  }
282
312
 
313
+ function tabletype(elemtype: BytecodeFragment, limits: BytecodeFragment) {
314
+ return [elemtype, limits];
315
+ }
316
+
317
+ function table(tabletype: BytecodeFragment) {
318
+ return tabletype;
319
+ }
320
+
321
+ function tablesec(tables: BytecodeFragment[]) {
322
+ return section(SECTION_ID_TABLE, vec(tables));
323
+ }
324
+
325
+ const elemtype = { funcref: 0x70 };
326
+
327
+ const tableidx = u32;
328
+
329
+ const start = funcidx;
330
+
331
+ // st:start
332
+ function startsec(st: BytecodeFragment) {
333
+ return section(SECTION_ID_START, st);
334
+ }
335
+
336
+ // x:memidx e:expr b∗:vec(byte)
337
+ function data(
338
+ x: BytecodeFragment,
339
+ e: BytecodeFragment,
340
+ bs: BytecodeFragment[],
341
+ ) {
342
+ return [x, e, vec(bs)];
343
+ }
344
+
345
+ function datasec(segs: BytecodeFragment[]) {
346
+ return section(SECTION_ID_DATA, vec(segs));
347
+ }
348
+
349
+ // x:tableidx e:expr y∗:vec(funcidx)
350
+ function elem(
351
+ x: BytecodeFragment,
352
+ e: BytecodeFragment,
353
+ ys: BytecodeFragment[],
354
+ ) {
355
+ return [x, e, vec(ys)];
356
+ }
357
+
358
+ function elemsec(segs: BytecodeFragment[]) {
359
+ return section(SECTION_ID_ELEMENT, vec(segs));
360
+ }
361
+
283
362
  export {
284
363
  blocktype,
285
364
  BytecodeFragment,
286
365
  code,
287
366
  codesec,
367
+ data,
368
+ datasec,
369
+ elem,
370
+ elemsec,
371
+ elemtype,
288
372
  export_,
289
373
  exportdesc,
290
374
  exportsec,
@@ -301,11 +385,19 @@ export {
301
385
  importdesc,
302
386
  importsec,
303
387
  instr,
388
+ limits,
304
389
  locals,
390
+ mem,
391
+ memsec,
305
392
  module,
306
393
  mut,
307
394
  name,
308
395
  section,
396
+ start,
397
+ startsec,
398
+ table,
399
+ tablesec,
400
+ tabletype,
309
401
  typeidx,
310
402
  typesec,
311
403
  u32,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wasmgroundup/emit",
3
3
  "description": "A library for creating binary-encoded WebAssembly modules",
4
- "version": "0.2.10",
4
+ "version": "0.2.11",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "repository": {