-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.d.ts
94 lines (87 loc) · 2.8 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/** Post-MVP WebAssembly features to legalize. */
interface WasmFeatures { // see: https://github.com/WebAssembly/wabt/blob/main/src/feature.def#L25-L35
/** Experimental exception handling. */
exceptions?: boolean;
/** Import/export mutable globals. */
mutable_globals?: boolean;
/** Saturating float-to-int operators. */
sat_float_to_int?: boolean;
/** Sign-extension operators. */
sign_extension?: boolean;
/** SIMD support. */
simd?: boolean;
/** Threading support. */
threads?: boolean;
/** Typed function references. */
function_references?: boolean;
/** Multi-value. */
multi_value?: boolean;
/** Tail-call support. */
tail_call?: boolean;
/** Bulk-memory operations. */
bulk_memory?: boolean;
/** Reference types (externref). */
reference_types?: boolean;
/** Custom annotation syntax. */
annotations?: boolean;
/** Code metadata. */
code_metadata?: boolean;
/** Garbage collection. */
gc?: boolean;
/** 64-bit memory */
memory64?: boolean;
/** Extended constant expressions. */
extended_const?: boolean;
/** Relaxed SIMD. */
relaxed_simd?: boolean;
}
/** Options modifying the behavior of `readWasm`. */
interface ReadWasmOptions {
/** Reads textual names from the name section. */
readDebugNames?: boolean;
}
/** Options modifying the behavior of `WasmModule#toText`. */
interface ToTextOptions {
foldExprs?: boolean;
inlineExport?: boolean;
}
/** Options modifying the behavior of `WasmModule#toBinary`. */
interface ToBinaryOptions {
log?: boolean;
canonicalize_lebs?: boolean;
relocatable?: boolean;
write_debug_names?: boolean;
}
/** Result object of `WasmModule#toBinary`. */
interface ToBinaryResult {
/** The wasm binary buffer. */
buffer: Uint8Array;
/** Generated log output. */
log: string;
}
/** A class representing a WebAssembly module. */
declare class WasmModule {
constructor(module_addr: number);
/** Validates the module. Throws if not valid. */
validate(): void;
/** Resolves names to indexes. */
resolveNames(): void;
/** Generates textual names for function types, globals, labels etc. */
generateNames(): void;
/** Applies textual names. Throws on error. */
applyNames(): void;
/** Converts the module to wat text format. */
toText(options: ToTextOptions): string;
/** Converts the module to a wasm binary. */
toBinary(options: ToBinaryOptions): ToBinaryResult;
/** Disposes the module and frees its resources. */
destroy(): void;
}
interface WabtModule {
/** Parses a WebAssembly text format source to a module. */
parseWat(filename: string, buffer: string | Uint8Array, options?: WasmFeatures): WasmModule;
/** Reads a WebAssembly binary to a module. */
readWasm(buffer: Uint8Array, options: ReadWasmOptions & WasmFeatures): WasmModule;
}
declare function wabt(): Promise<WabtModule>
export = wabt