Skip to content

Commit 1020b28

Browse files
committed
Update typings and README [ci skip]
1 parent bcdf38d commit 1020b28

File tree

3 files changed

+61
-78
lines changed

3 files changed

+61
-78
lines changed

API.md

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The API is documented in the rest of this document.
3232
- [Atomic memory accesses 🦄](#atomic-memory-accesses-)
3333
- [Atomic read-modify-write operations 🦄](#atomic-read-modify-write-operations-)
3434
- [Atomic wait and wake operations 🦄](#atomic-wait-and-wake-operations-)
35+
- [Sign extension operations 🦄](#sign-extension-operations-)
3536
- [Expression manipulation](#expression-manipulation)
3637
- [Relooper](#relooper)
3738
- [Source maps](#source-maps)
@@ -83,6 +84,9 @@ The API is documented in the rest of this document.
8384
* Module#**getFunctionTypeBySignature**(resultType: `Type`, paramTypes: `Type[]`): `Signature`<br />
8485
Gets an existing function type by its parametric signature. Returns `0` if there is no such function type.
8586

87+
* Module#**removeFunctionType**(name: `string`): `void`<br />
88+
Removes a function type.
89+
8690
* Module#**addFunction**(name: `string`, functionType: `Signature`, varTypes: `Type[]`, body: `Expression`): `Function`<br />
8791
Adds a function. `varTypes` indicate additional locals, in the given order.
8892

@@ -104,9 +108,6 @@ The API is documented in the rest of this document.
104108
* Module#**addGlobalImport**(internalName: `string`, externalModuleName: `string`, externalBaseName: `string`, globalType: `Type`): `Import`<br />
105109
Adds a global variable import. Imported globals must be immutable.
106110

107-
* Module#**removeImport**(internalName: `string`): `void`<br />
108-
Removes an import, by internal name.
109-
110111
* Module#**addFunctionExport**(internalName: `string`, externalName: `string`): `Export`<br />
111112
Adds a function export.
112113

@@ -119,10 +120,13 @@ The API is documented in the rest of this document.
119120
* Module#**addGlobalExport**(internalName: `string`, externalName: `string`): `Export`<br />
120121
Adds a global variable export. Exported globals must be immutable.
121122

123+
* Module#**addGlobal**(name: `string`, type: `Type`, mutable: `number`, value: `Expression`): `Global`<br />
124+
Adds a global instance variable.
125+
122126
* Module#**removeExport**(externalName: `string`): `void`<br />
123127
Removes an export, by external name.
124128

125-
* Module#**setFunctionTable**(funcs: `Function[]`): `void`<br />
129+
* Module#**setFunctionTable**(initial: `number`, maximum: `number`, funcs: `string[]`): `void`<br />
126130
Sets the contents of the function table. There's just one table for now, using name `"0"`.
127131

128132
* Module#**setMemory**(initial: `number`, maximum: `number`, exportName: `string | null`, segments: `MemorySegment[]`): `void`<br />
@@ -144,26 +148,29 @@ The API is documented in the rest of this document.
144148
* **getFunctionInfo**(ftype: `Function`: `FunctionInfo`<br />
145149
Obtains information about a function.
146150

147-
* FunctionInfo#**name**: `string | null`
151+
* FunctionInfo#**name**: `string`
152+
* FunctionInfo#**module**: `string | null` (if imported)
153+
* FunctionInfo#**base**: `string | null` (if imported)
148154
* FunctionInfo#**type**: `FunctionType`
149155
* FunctionInfo#**params**: `Type[]`
150156
* FunctionInfo#**result**: `Type`
151157
* FunctionInfo#**vars**: `Type`
152158
* FunctionInfo#**body**: `Expression`
153159

154-
* **getImportInfo**(import_: `Import`): `ImportInfo`<br />
160+
* **getGlobalInfo**(global: `Global`): `GlobalInfo`<br />
155161
Obtains information about an import, always including:
156162

157-
* ImportInfo#**kind**: `ExternalKind`
158-
* ImportInfo#**module**: `string`
159-
* ImportInfo#**base**: `string`
160-
* ImportInfo#**name**: `string`
163+
* GlobalInfo#**name**: `string`
164+
* GlobalInfo#**module**: `string | null` (if imported)
165+
* GlobalInfo#**base**: `string | null` (if imported)
166+
* GlobalInfo#**type**: `Type`
161167

162-
Additional properties depend on the expression's `kind` and are usually equivalent to the respective parameters when creating such an import:
168+
* **getExportInfo**(export_: `Export`): `ExportInfo`<br />
169+
Obtains information about an export.
163170

164-
* GlobalImportInfo#**globalType**: `Type`
165-
>
166-
* FunctionImportInfo#**functionType**: `FunctionType`
171+
* ExportInfo#**kind**: `ExternalKind`
172+
* ExportInfo#**name**: `string`
173+
* ExportInfo#**value**: `string`
167174

168175
Possible `ExternalKind` values are:
169176

@@ -172,13 +179,6 @@ The API is documented in the rest of this document.
172179
* **ExternalMemory**: `ExternalKind`
173180
* **ExternalGlobal**: `ExternalKind`
174181

175-
* **getExportInfo**(export_: `Export`): `ExportInfo`<br />
176-
Obtains information about an export.
177-
178-
* ExportInfo#**kind**: `ExternalKind`
179-
* ExportInfo#**name**: `string`
180-
* ExportInfo#**value**: `string`
181-
182182
### Module validation
183183

184184
* Module#**validate**(): `boolean`<br />
@@ -284,19 +284,19 @@ The API is documented in the rest of this document.
284284

285285
#### [Variable accesses](http://webassembly.org/docs/semantics/#local-variables)
286286

287-
* Module#**getLocal/get_local**(index: `number`, type: `Type`): `Expression`<br />
287+
* Module#**get_local/getLocal**(index: `number`, type: `Type`): `Expression`<br />
288288
Creates a get_local for the local at the specified index. Note that we must specify the type here as we may not have created the local being called yet.
289289

290-
* Module#**setLocal/set_local**(index: `number`, value: `Expression`): `Expression`<br />
290+
* Module#**set_local/setLocal**(index: `number`, value: `Expression`): `Expression`<br />
291291
Creates a set_local for the local at the specified index.
292292

293-
* Module#**teeLocal/tee_local**(index: `number`, value: `Expression`): `Expression`<br />
293+
* Module#**tee_local/teeLocal**(index: `number`, value: `Expression`): `Expression`<br />
294294
Creates a tee_local for the local at the specified index. A tee differs from a set in that the value remains on the stack.
295295

296-
* Module#**getGlobal/get_global**(name: `string`, type: `Type`): `Expression`<br />
296+
* Module#**get_global/getGlobal**(name: `string`, type: `Type`): `Expression`<br />
297297
Creates a get_global for the global with the specified name. Note that we must specify the type here as we may not have created the global being called yet.
298298

299-
* Module#**setGlobal/set_global**(name: `string`, value: `Expression`): `Expression`<br />
299+
* Module#**set_global/setGlobal**(name: `string`, value: `Expression`): `Expression`<br />
300300
Creates a set_global for the global with the specified name.
301301

302302
#### [Integer operations](http://webassembly.org/docs/semantics/#32-bit-integer-operators)
@@ -441,10 +441,7 @@ The API is documented in the rest of this document.
441441
* Module#**call**(name: `string`, operands: `Expression[]`, returnType: `Type`): `Expression`<br />
442442
Creates a call to a function. Note that we must specify the return type here as we may not have created the function being called yet.
443443

444-
* Module#**callImport/call_import**(name: `string`, operands: `Expression[]`, returnType: `Type`): `Expression`<br />
445-
Similar to **call**, but calls an imported function.
446-
447-
* Module#**callIndirect/call_indirect**(target: `Expression`, operands: `Expression[]`, returnType: `Type`): `Expression`<br />
444+
* Module#**call_indirect/callIndirect**(target: `Expression`, operands: `Expression[]`, returnType: `Type`): `Expression`<br />
448445
Similar to **call**, but calls indirectly, i.e., via a function pointer, so an expression replaces the name as the called value.
449446

450447
#### [Linear memory accesses](http://webassembly.org/docs/semantics/#linear-memory-accesses)
@@ -478,9 +475,8 @@ The API is documented in the rest of this document.
478475

479476
#### [Host operations](http://webassembly.org/docs/semantics/#resizing)
480477

481-
* Module#**currentMemory/current_memory**(): `Expression`
482-
* Module#**growMemory/get_memory**(value: `number`): `Expression`
483-
* Module#**hasFeature/has_feature**(name: `string`): `Expression` 🦄
478+
* Module#**current_memory/currentMemory**(): `Expression`
479+
* Module#**grow_memory/growMemory**(value: `number`): `Expression`
484480

485481
#### [Atomic memory accesses](https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#atomic-memory-accesses) 🦄
486482

@@ -559,6 +555,15 @@ The API is documented in the rest of this document.
559555
* Module#i64.**wait**(ptr: `Expression`, expected: `Expression`, timeout: `Expression`): `Expression`
560556
* Module#**wake**(ptr: `Expression`, wakeCount: `Expression`): `Expression`
561557

558+
#### [Sign extension operations](https://github.com/WebAssembly/sign-extension-ops/blob/master/proposals/sign-extension-ops/Overview.md) 🦄
559+
560+
* Module#i32.**extend8_s**(value: `Expression`): `Expression`
561+
* Module#i32.**extend16_s**(value: `Expression`): `Expression`
562+
>
563+
* Module#i64.**extend8_s**(value: `Expression`): `Expression`
564+
* Module#i64.**extend16_s**(value: `Expression`): `Expression`
565+
* Module#i64.**extend32_s**(value: `Expression`): `Expression`
566+
562567
### Expression manipulation
563568

564569
* **getExpressionId**(expr: `Expression`): `ExpressionId`<br />

README.md

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,6 @@ API
175175
* Module#**addGlobalImport**(internalName: `string`, externalModuleName: `string`, externalBaseName: `string`, globalType: `Type`): `Import`<br />
176176
Adds a global variable import. Imported globals must be immutable.
177177

178-
* Module#**removeImport**(internalName: `string`): `void`<br />
179-
Removes an import, by internal name.
180-
181178
* Module#**addFunctionExport**(internalName: `string`, externalName: `string`): `Export`<br />
182179
Adds a function export.
183180

@@ -196,7 +193,7 @@ API
196193
* Module#**removeExport**(externalName: `string`): `void`<br />
197194
Removes an export, by external name.
198195

199-
* Module#**setFunctionTable**(funcs: `Function[]`): `void`<br />
196+
* Module#**setFunctionTable**(initial: `number`, maximum: `number`, funcs: `string[]`): `void`<br />
200197
Sets the contents of the function table. There's just one table for now, using name `"0"`.
201198

202199
* Module#**setMemory**(initial: `number`, maximum: `number`, exportName: `string | null`, segments: `MemorySegment[]`): `void`<br />
@@ -218,26 +215,29 @@ API
218215
* **getFunctionInfo**(ftype: `Function`: `FunctionInfo`<br />
219216
Obtains information about a function.
220217

221-
* FunctionInfo#**name**: `string | null`
218+
* FunctionInfo#**name**: `string`
219+
* FunctionInfo#**module**: `string | null` (if imported)
220+
* FunctionInfo#**base**: `string | null` (if imported)
222221
* FunctionInfo#**type**: `FunctionType`
223222
* FunctionInfo#**params**: `Type[]`
224223
* FunctionInfo#**result**: `Type`
225224
* FunctionInfo#**vars**: `Type`
226225
* FunctionInfo#**body**: `Expression`
227226

228-
* **getImportInfo**(import_: `Import`): `ImportInfo`<br />
227+
* **getGlobalInfo**(global: `Global`): `GlobalInfo`<br />
229228
Obtains information about an import, always including:
230229

231-
* ImportInfo#**kind**: `ExternalKind`
232-
* ImportInfo#**module**: `string`
233-
* ImportInfo#**base**: `string`
234-
* ImportInfo#**name**: `string`
230+
* GlobalInfo#**name**: `string`
231+
* GlobalInfo#**module**: `string | null` (if imported)
232+
* GlobalInfo#**base**: `string | null` (if imported)
233+
* GlobalInfo#**type**: `Type`
235234

236-
Additional properties depend on the expression's `kind` and are usually equivalent to the respective parameters when creating such an import:
235+
* **getExportInfo**(export_: `Export`): `ExportInfo`<br />
236+
Obtains information about an export.
237237

238-
* GlobalImportInfo#**globalType**: `Type`
239-
>
240-
* FunctionImportInfo#**functionType**: `FunctionType`
238+
* ExportInfo#**kind**: `ExternalKind`
239+
* ExportInfo#**name**: `string`
240+
* ExportInfo#**value**: `string`
241241

242242
Possible `ExternalKind` values are:
243243

@@ -246,13 +246,6 @@ API
246246
* **ExternalMemory**: `ExternalKind`
247247
* **ExternalGlobal**: `ExternalKind`
248248

249-
* **getExportInfo**(export_: `Export`): `ExportInfo`<br />
250-
Obtains information about an export.
251-
252-
* ExportInfo#**kind**: `ExternalKind`
253-
* ExportInfo#**name**: `string`
254-
* ExportInfo#**value**: `string`
255-
256249
### Module validation
257250

258251
* Module#**validate**(): `boolean`<br />
@@ -515,9 +508,6 @@ API
515508
* Module#**call**(name: `string`, operands: `Expression[]`, returnType: `Type`): `Expression`<br />
516509
Creates a call to a function. Note that we must specify the return type here as we may not have created the function being called yet.
517510

518-
* Module#**call_import/callImport**(name: `string`, operands: `Expression[]`, returnType: `Type`): `Expression`<br />
519-
Similar to **call**, but calls an imported function.
520-
521511
* Module#**call_indirect/callIndirect**(target: `Expression`, operands: `Expression[]`, returnType: `Type`): `Expression`<br />
522512
Similar to **call**, but calls indirectly, i.e., via a function pointer, so an expression replaces the name as the called value.
523513

@@ -554,7 +544,6 @@ API
554544

555545
* Module#**current_memory/currentMemory**(): `Expression`
556546
* Module#**grow_memory/growMemory**(value: `number`): `Expression`
557-
* Module#**has_feature/hasFeature**(name: `string`): `Expression` 🦄
558547

559548
#### [Atomic memory accesses](https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#atomic-memory-accesses) 🦄
560549

index.d.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ declare module binaryen {
1515
const BreakId: ExpressionId;
1616
const SwitchId: ExpressionId;
1717
const CallId: ExpressionId;
18-
const CallImportId: ExpressionId;
1918
const CallIndirectId: ExpressionId;
2019
const GetLocalid: ExpressionId;
2120
const SetLocalId: ExpressionId;
@@ -327,13 +326,12 @@ declare module binaryen {
327326
addTableImport(internalName: string, externalModuleName: string, externalBaseName: string): Import;
328327
addMemoryImport(internalName: string, externalModuleName: string, externalBaseName: string): Import;
329328
addGlobalImport(internalName: string, externalModuleName: string, externalBaseName: string, globalType: Type): Import;
330-
removeImport(internalName: string): void;
331329
addFunctionExport(internalName: string, externalName: string): Export;
332330
addTableExport(internalName: string, externalName: string): Export;
333331
addMemoryExport(internalName: string, externalName: string): Export;
334332
addGlobalExport(internalName: string, externalName: string): Export;
335333
removeExport(externalName: string): void;
336-
setFunctionTable(funcs: number[]): void;
334+
setFunctionTable(initial: number, maximum: number, funcs: number[]): void;
337335
setMemory(initial: number, maximum: number, exportName?: string | null, segments?: MemorySegment[]): void;
338336
setStart(start: binaryen.Function): void;
339337

@@ -367,7 +365,6 @@ declare module binaryen {
367365
/* alias */ br_if(label: string, condition?: Expression, value?: Expression): Statement;
368366
switch(labels: string[], defaultLabel: string, condition: Expression, value?: Expression): Statement;
369367
call(name: string, operands: Expression[], type: Type): Expression;
370-
callImport(name: string, operands: Expression[], type: Type): Expression;
371368
/* alias */ call_import(name: string, operands: Expression[], type: Type): Expression;
372369
callIndirect(target: Expression, operands: Expression[], type: Type): Expression;
373370
/* alias */ call_indirect(target: Expression, operands: Expression[], type: Type): Expression;
@@ -389,8 +386,6 @@ declare module binaryen {
389386
/* alias */ grow_memory(value: Expression): Expression;
390387
currentMemory(): Expression;
391388
/* alias */ current_memory(): Expression;
392-
hasFeature(name: string): Expression;
393-
/* alias */ has_feature(name: string): Expression;
394389
unreachable(): Statement;
395390
wake(ptr: Expression, wakeCount: Expression): Expression;
396391
}
@@ -560,28 +555,22 @@ declare module binaryen {
560555

561556
interface FunctionInfo {
562557
name: string;
563-
ype: FunctionType;
558+
module: string | null;
559+
base: string | null;
560+
type: FunctionType;
564561
params: Type[];
565562
result: Type;
566563
vars: Type[];
567564
body: Expression
568565
}
569566

570-
function getImportInfo(import_: Import): ImportInfo;
567+
function getGlobalInfo(global: Global): GlobalInfo;
571568

572-
interface ImportInfo {
573-
kind: ExternalKind;
574-
module: string;
575-
base: string;
569+
interface GlobalInfo {
576570
name: string;
577-
}
578-
579-
interface GlobalImportInfo extends ImportInfo {
580-
globalType: Type;
581-
}
582-
583-
interface FunctionImportInfo extends ImportInfo {
584-
functionType: string;
571+
module: string | null;
572+
base: string | null;
573+
type: Type;
585574
}
586575

587576
function getExportInfo(export_: Export): ExportInfo;

0 commit comments

Comments
 (0)