@@ -18,7 +18,7 @@ var binaryen = require("binaryen");
1818// Create a module with a single function
1919var myModule = new binaryen.Module ();
2020
21- myModule .addFunction (" add" , myModule . addFunctionType ( " iii " , binaryen .i32 , [ binaryen .i32 , binaryen .i32 ]) , [ binaryen .i32 ],
21+ myModule .addFunction (" add" , binaryen . createType ([ binaryen .i32 , binaryen .i32 ]) , binaryen .i32 , [ binaryen .i32 ],
2222 myModule .block (null , [
2323 myModule .setLocal (2 ,
2424 myModule .i32 .add (
@@ -71,7 +71,6 @@ or you can use one of the [previous versions](https://github.com/AssemblyScript/
7171
7272API
7373---
74- <!-- START API.md -->
7574
7675<!-- START doctoc generated TOC please keep comment here to allow auto update -->
7776<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
132131 * ** auto** : ` Type ` <br />
133132 Special type used in ** Module#block** exclusively. Lets the API figure out a block's result type automatically.
134133
134+ * ** createType** (types: ` Type[] ` ): ` Type ` <br />
135+ Creates a multi-value type from an array of types.
136+
137+ * ** expandType** (type: ` Type ` ): ` Type[] ` <br />
138+ Expands a multi-value type to an array of types.
139+
135140### Module construction
136141
137142 * new ** Module** (): ` Module ` <br />
@@ -145,25 +150,16 @@ API
145150
146151### Module manipulation
147152
148- * Module#** addFunctionType** (name: ` string ` , resultType: ` Type ` , paramTypes: ` Type[] ` ): ` Signature ` <br />
149- Adds a new function type.
150-
151- * Module#** getFunctionTypeBySignature** (resultType: ` Type ` , paramTypes: ` Type[] ` ): ` Signature ` <br />
152- Gets an existing function type by its parametric signature. Returns ` 0 ` if there is no such function type.
153-
154- * Module#** removeFunctionType** (name: ` string ` ): ` void ` <br />
155- Removes a function type.
156-
157- * Module#** addFunction** (name: ` string ` , functionType: ` Signature ` , varTypes: ` Type[] ` , body: ` Expression ` ): ` Function ` <br />
158- Adds a function. ` varTypes ` indicate additional locals, in the given order.
153+ * Module#** addFunction** (name: ` string ` , params: ` Type ` , results: ` Type ` , vars: ` Type[] ` , body: ` Expression ` ): ` Function ` <br />
154+ Adds a function. ` vars ` indicate additional locals, in the given order.
159155
160156* Module#** getFunction** (name: ` string ` ): ` Function ` <br />
161157 Gets a function, by name,
162158
163159* Module#** removeFunction** (name: ` string ` ): ` void ` <br />
164160 Removes a function, by name.
165161
166- * Module#** addFunctionImport** (internalName: ` string ` , externalModuleName: ` string ` , externalBaseName: ` string ` , functionType : ` Signature ` ): ` Import ` <br />
162+ * Module#** addFunctionImport** (internalName: ` string ` , externalModuleName: ` string ` , externalBaseName: ` string ` , params : ` Type ` , results: ` Type ` ): ` Import ` <br />
167163 Adds a function import.
168164
169165* Module#** addTableImport** (internalName: ` string ` , externalModuleName: ` string ` , externalBaseName: ` string ` ): ` Import ` <br />
@@ -211,22 +207,14 @@ API
211207* Module#** autoDrop** (): ` void ` <br />
212208 Enables automatic insertion of ` drop ` operations where needed. Lets you not worry about dropping when creating your code.
213209
214- * ** getFunctionTypeInfo** (ftype: ` FunctionType ` : ` FunctionTypeInfo ` <br />
215- Obtains information about a function type.
216-
217- * FunctionTypeInfo#** name** : ` string | null `
218- * FunctionTypeInfo#** params** : ` Type[] `
219- * FunctionTypeInfo#** result** : ` Type `
220-
221210* ** getFunctionInfo** (ftype: ` Function ` : ` FunctionInfo ` <br />
222211 Obtains information about a function.
223212
224213 * FunctionInfo#** name** : ` string `
225214 * FunctionInfo#** module** : ` string | null ` (if imported)
226215 * FunctionInfo#** base** : ` string | null ` (if imported)
227- * FunctionInfo#** type** : ` FunctionType `
228- * FunctionInfo#** params** : ` Type[] `
229- * FunctionInfo#** result** : ` Type `
216+ * FunctionInfo#** params** : ` Type `
217+ * FunctionInfo#** results** : ` Type `
230218 * FunctionInfo#** vars** : ` Type `
231219 * FunctionInfo#** body** : ` Expression `
232220
@@ -513,12 +501,18 @@ API
513501
514502#### [ Function calls] ( http://webassembly.org/docs/semantics/#calls )
515503
516- * Module#** call** (name: ` string ` , operands: ` Expression[] ` , returnType: ` Type ` ): ` Expression ` <br />
517- 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.
504+ * Module#** call** (name: ` string ` , operands: ` Expression[] ` , params: ` Type ` , results: ` Type ` ): ` Expression ` <br />
505+ Creates a call to a function. Note that we must specify the parameter and result type here.
506+
507+ * Module#** return_call** (name: ` string ` , operands: ` Expression[] ` , params: ` Type ` , results: ` Type ` ): ` Expression ` <br />
508+ Like ** call** , but creates a tail-call. 🦄
518509
519- * Module#** call_indirect/callIndirect ** (target: ` Expression ` , operands: ` Expression[] ` , returnType : ` Type ` ): ` Expression ` <br />
510+ * Module#** call_indirect** (target: ` Expression ` , operands: ` Expression[] ` , params: ` Type ` , results : ` Type ` ): ` Expression ` <br />
520511 Similar to ** call** , but calls indirectly, i.e., via a function pointer, so an expression replaces the name as the called value.
521512
513+ * Module#** return_call_indirect** (target: ` Expression ` , operands: ` Expression[] ` , params: ` Type ` , results: ` Type ` ): ` Expression ` <br />
514+ Like ** call_indirect** , but creates a tail-call. 🦄
515+
522516#### [ Linear memory accesses] ( http://webassembly.org/docs/semantics/#linear-memory-accesses )
523517
524518* Module#i32.** load** (offset: ` number ` , align: ` number ` , ptr: ` Expression ` ): ` Expression ` <br />
818812
819813* Module#** interpret** (): ` void ` <br />
820814 Runs the module in the interpreter, calling the start function.
821-
822- <!-- END API.md -->
0 commit comments