Add table section support to lib/parse

Originally part of #288
This commit is contained in:
dcodeIO
2018-10-03 03:30:00 +02:00
parent eeb8a8fd6c
commit 59e2a63b83
8 changed files with 922 additions and 834 deletions

View File

@ -42,11 +42,11 @@ export enum NameType {
Local = 2
}
/** Maximum number of pages. */
/** Maximum number of memory pages. */
export const MAX_PAGES = 0xffff;
/** Maximum number of tables. */
export const MAX_TABLES = 1; // MVP
/** Maximum number of table elements. */
export const MAX_ELEMS = 0xffffffff;
/** WebAssembly opcodes. */
export enum Opcode { // just a few of these are actually used

View File

@ -31,6 +31,8 @@ export interface ParseOptions {
onMemory?(index: number, initial: number, maximum: number, flags: number): void;
/** Called with each function if the function section is evaluated. */
onFunction?(index: number, typeIndex: number): void;
/** Called with each table if the table section is evaluated.*/
onTable?(index: number, type: Type, initial: number, maximum: number, flags: number): void;
/** Called with each global if the global section is evaluated. */
onGlobal?(index: number, type: Type, mutability: number): void;
/** Called with the start function index if the start section is evaluated. */
@ -82,6 +84,7 @@ export function parse(binary: Uint8Array, options?: ParseOptions): void {
"onGlobalImport",
"onMemory",
"onFunction",
"onTable",
"onGlobal",
"onExport",
"onStart",