binaryen.js
===========
**binaryen.js** is a port of [Binaryen](https://github.com/WebAssembly/binaryen) to the Web, allowing you to generate [WebAssembly](https://webassembly.org) using a JavaScript API.
<a href="https://github.com/AssemblyScript/binaryen.js/actions?query=workflow%3ABuild"><img src="https://img.shields.io/github/workflow/status/AssemblyScript/binaryen.js/Build/main?label=build&logo=github" alt="Build status" /></a>
<a href="https://www.npmjs.com/package/binaryen"><img src="https://img.shields.io/npm/v/binaryen.svg?label=latest&color=007acc&logo=npm" alt="npm version" /></a>
<a href="https://www.npmjs.com/package/binaryen"><img src="https://img.shields.io/npm/v/binaryen/nightly.svg?label=nightly&color=007acc&logo=npm" alt="npm nightly version" /></a>
Usage
-----
```
$> npm install binaryen
```
```js
import binaryen from "binaryen";
// Create a module with a single function
var myModule = new binaryen.Module();
myModule.addFunction("add", binaryen.createType([ binaryen.i32, binaryen.i32 ]), binaryen.i32, [ binaryen.i32 ],
myModule.block(null, [
myModule.local.set(2,
myModule.i32.add(
myModule.local.get(0, binaryen.i32),
myModule.local.get(1, binaryen.i32)
)
),
myModule.return(
myModule.local.get(2, binaryen.i32)
)
])
);
myModule.addFunctionExport("add", "add");
// Optimize the module using default passes and levels
myModule.optimize();
// Validate the module
if (!myModule.validate())
throw new Error("validation error");
// Generate text format and binary
var textData = myModule.emitText();
var wasmData = myModule.emitBinary();
// Example usage with the WebAssembly API
var compiled = new WebAssembly.Module(wasmData);
var instance = new WebAssembly.Instance(compiled, {});
console.log(instance.exports.add(41, 1));
```
The buildbot also publishes nightly versions once a day if there have been changes. The latest nightly can be installed through
```
$> npm install binaryen@nightly
```
or you can use one of the [previous versions](https://github.com/AssemblyScript/binaryen.js/tags) instead if necessary.
### Usage with a CDN
* From GitHub via [jsDelivr](https://www.jsdelivr.com):<br />
`https://cdn.jsdelivr.net/gh/AssemblyScript/binaryen.js@VERSION/index.js`
* From npm via [jsDelivr](https://www.jsdelivr.com):<br />
`https://cdn.jsdelivr.net/npm/binaryen@VERSION/index.js`
* From npm via [unpkg](https://unpkg.com):<br />
`https://unpkg.com/binaryen@VERSION/index.js`
Replace `VERSION` with a [specific version](https://github.com/AssemblyScript/binaryen.js/releases) or omit it (not recommended in production) to use main/latest.
### Command line
The package includes Node.js builds of [wasm-opt](https://github.com/WebAssembly/binaryen#wasm-opt) and [wasm2js](https://github.com/WebAssembly/binaryen#wasm2js).
API
---
**Please note** that the Binaryen API is evolving fast and that definitions and documentation provided by the package tend to get out of sync despite our best efforts. It's a bot after all. If you rely on binaryen.js and spot an issue, please consider sending a PR our way by updating [index.d.ts](./index.d.ts) and [README.md](./README.md) to reflect the [current API](https://github.com/WebAssembly/binaryen/blob/main/src/js/binaryen.js-post.js).
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
### Contents
- [Types](#types)
- [Module construction](#module-construction)
- [Module manipulation](#module-manipulation)
- [Module validation](#module-validation)
- [Module optimization](#module-optimization)
- [Module creation](#module-creation)
- [Expression construction](#expression-construction)
- [Control flow](#control-flow)
- [Variable accesses](#variable-accesses)
- [Integer operations](#integer-operations)
- [Floating point operations](#floating-point-operations)
- [Datatype conversions](#datatype-conversions)
- [Function calls](#function-calls)
- [Linear memory accesses](#linear-memory-accesses)
- [Host operations](#host-operations)
- [Vector operations ð¦](#vector-operations-)
- [Atomic memory accesses ð¦](#atomic-memory-accesses-)
- [Atomic read-modify-write operations ð¦](#atomic-read-modify-write-operations-)
- [Atomic wait and notify operations ð¦](#atomic-wait-and-notify-operations-)
- [Sign extension operations ð¦](#sign-extension-operations-)
- [Multi-value operations ð¦](#multi-value-operations-)
- [Exception handling operations ð¦](#exception-handling-operations-)
- [Reference types operations ð¦](#reference-types-operations-)
- [Bulk memory operations ð¦](#bulk-memory-operations-)
- [Expression manipulation](#expression-manipulation)
- [Relooper](#relooper)
- [Source maps](#source-maps)
- [Debugging](#debugging)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
[Future features](http://webassembly.org/docs/future-features/) ð¦ might not be supported by all runtimes.
### Types
* **none**: `Type`<br />
The none type, e.g., `void`.
* **i32**: `Type`<br />
32-bit integer type.
* **i64**: `Type`<br />
64-bit integer type.
* **f32**: `Type`<br />
32-bit float type.
* **f64**: `Type`<br />
64-bit float (double) type.
* **v128**: `Type`<br />
128-bit vector type. ð¦
* **funcref**: `Type`<br />
A function reference. ð¦
* **anyref**: `Type`<br />
Any host reference. ð¦
* **nullref**: `Type`<br />
A null reference. ð¦
* **exnref**: `Type`<br />
An exception reference. ð¦
* **unreachable**: `Type`<br />
Special type indicating unreachable code when obtaining information about an expression.
* **auto**: `Type`<br />
Special type used in **Module#block** exclusively. Lets the API figure out a block's result type automatically.
* **createType**(types: `Type[]`): `Type`<br />
Creates a multi-value type from an array of types.
* **expandType**(type: `Type`): `Type[]`<br />
Expands a multi-value type to an array of types.
### Module construction
* new **Module**()<br />
Constructs a new module.
* **parseText**(text: `string`): `Module`<br />
Creates a module from Binaryen's s-expression text format (not official stack-style text format).
* **readBinary**(data: `Uint8Array`): `Module`<br />
Creates a module from binary data.
### Module manipulation
* Module#**addFunction**(name: `string`, params: `Type`, results: `Type`, vars: `Type[]`, body: `ExpressionRef`): `FunctionRef`<br />
Adds a function. `vars` indicate additional locals, in the given order.
* Module#**getFunction**(name: `string`): `FunctionRef`<br />
Gets a function, by name,
* Module#**removeFunction**(name: `string`): `void`<br />
Removes a function, by name.
* Module#**getNumFunctions**(): `number`<br />
Gets the number of functions within the module.
* Module#**getFunctionByIndex**(index: `number`): `FunctionRef`<br />
Gets the function at the specified index.
* Module#**addFunctionImport**(internalName: `string`, externalModuleName: `string`, externalBaseName: `string`, params: `Type`, results: `Type`): `void`<br />
Adds a function import.
* Module#**addTableImport**(internalName: `string`, externalModuleName: `string`, externalBaseName: `string`): `void`<br />
Adds a table import. There's just one table for now, using name `"0"`.
* Module#**addMemoryImport**(internalName: `string`, externalModuleName: `string`, externalBaseName: `string`): `void`<br />
Adds a memory import. There's just one memory for now, using name `"0"`.
* Module#**addGlobalImport**(internalName: `string`, externalModuleName: `string`, externalBaseName: `string`, globalType: `Type`): `void`<br />
Adds a global variable import. Imported globals must be immutable.
* Module#**addFunctionExport**(internalName: `string`, externalName: `string`): `ExportRef`<br />
Adds a function export.
* Module#**addTable
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
项目Unity开发版本是:Unity 2021.3.19f1 利用这套框架可以开发出热更新游戏,这套框架也有对应的文档, 文档地址:https://docs.xgamedev.net/zh/documents/0.8/ 这套框架作者加了很多其他的插件以及功能在其中,比如查看日志的插件ConsolePro和Reporter以及微信小游戏开发工具等等。
资源推荐
资源详情
资源评论
收起资源包目录
Unity热更新游戏开发框架(目前已适配Android、IOS、WebGL、微信小游戏)这几个主流平台 (2000个子文件)
WxWasmSDKEditor.asmdef 564B
YooAsset.Editor.asmdef 483B
Malee.ReorderableList.Editor.asmdef 411B
WxWasmSDKRuntime.asmdef 388B
Malee.ReorderableList.asmdef 329B
YooAsset.asmdef 316B
ILRuntime.asmdef 316B
ProjectSettings.asset 20KB
QualitySettings.asset 6KB
InputManager.asset 6KB
AssetBundleCollectorSetting.asset 4KB
GraphicsSettings.asset 3KB
Physics2DSettings.asset 2KB
MiniGameConfig.asset 2KB
EditorSettings.asset 1KB
NavMeshAreas.asset 1KB
DynamicsManager.asset 1KB
MemorySettings.asset 1KB
UnityConnectSettings.asset 943B
PackageManagerSettings.asset 863B
AssetBundleBuilderSetting.asset 598B
EditorBuildSettings.asset 477B
AudioManager.asset 443B
VFXManager.asset 387B
TagManager.asset 378B
TimeManager.asset 202B
VersionControlSettings.asset 188B
XRSettings.asset 158B
PresetManager.asset 146B
ClusterInputManager.asset 114B
astcenc-avx2 626KB
astcenc-neon 546KB
brotli 1.58MB
brotli 833KB
build_info 48B
467495e87039942abfaeefcac211d313.bundle 11.16MB
3a0e1146e308dc839c398d4a1ce2cabc.bundle 11.15MB
30900cd4484f4e0fa7c5ee503b7457ce.bundle 287KB
896941e3a3df6314047415a18bec2020.bundle 276KB
c0e0cf4ab96522a08f10507e3c171e6a.bundle 236KB
58110d94e7e18b1fb2b6b01b46ea4a0b.bundle 228KB
b36783f41423d358000217b75b2ef4ad.bundle 129KB
3878bf0ba57e416f2ae185b4dbc09726.bundle 127KB
ac575ec0761eb6697d7e65e65af8a024.bundle 117KB
975666bdd3b055a6df32a06f8e1c5358.bundle 114KB
8b1046ca1ff63d6d5f070da6b41da811.bundle 23KB
df8cb34141aadb95861095c32771d7e1.bundle 17KB
164a5a7c5c28df34c43f424819b6c642.bundle 16KB
5b33df7e623dbd1d52a843e92aaaa185.bundle 16KB
34e14b580515f19524ee627c7ec48cfb.bundle 13KB
33441474bba07328e382485cbea71520.bundle 8KB
75571229c1830d6f8c51314f07874f79.bundle 8KB
da3b21d53c72fbf3751f717521900666.bundle 7KB
f81e8afdc0ca77599f8f2b34d63cfe0e.bundle 6KB
567803e3cb39897443cfc1c79e9a0743.bundle 5KB
ec04edc99fc9e2ddd6e499859abd1524.bundle 4KB
3cbc41320d701511c98fc9564d8c59db.bundle 3KB
b1e33d13b969074b350ce20babf96c36.bundle 1KB
036bab15651f8e5a0c253ab44d08aaa8.bundle 1KB
cf456433cf36c5b3bbedb6dca84173fd.bundle 1KB
bf06f792c446aeb9099539445fd0cefc.bundle 1KB
12e8c7707213e9b55ea8e212315d49d6.bundle 1KB
9cbcbfb8becc8ca2a54a84d87da299f2.bundle 1KB
HotUpdateScripts.pdb.bytes 168KB
HotUpdateScripts.bytes 71KB
HotUpdateScripts_expr.bytes 66KB
PackageManifest_Main_2024-04-30-938.bytes 5KB
PackageManifest_AddOn1_2024-04-30-938.bytes 378B
DesignTimeResolveAssemblyReferencesInput.cache 7KB
HotUpdateScripts.csproj.CoreCompileInputs.cache 42B
slim.conf 5KB
WXTextureTools.exe.config 540B
boot.config 0B
HotUpdateScripts.csproj.CopyComplete 0B
ILIntepreter.Register.cs 335KB
ILIntepreter.cs 323KB
WX.cs 190KB
RegisterMethodRedirection.cs 126KB
DebugService.cs 75KB
AppDomain.cs 67KB
WXConvertCore.cs 66KB
Reporter.cs 65KB
ReorderableList.cs 63KB
CLRRedirections.cs 61KB
Optimizer.Utils.cs 51KB
ILType.cs 47KB
JITCompiler.cs 43KB
WXBase.cs 43KB
BindingCodeGenerator.cs 42KB
MonoBehaviourAdapter.cs 42KB
UnityEngine_GameObject_Binding.cs 40KB
System_Runtime_CompilerServices_AsyncVoidMethodBuilder_Bindi.cs 37KB
DelegateAdapter.cs 36KB
OpCodeREnum.cs 36KB
CLRType.cs 35KB
OpCodeEnum.cs 35KB
ILMethod.cs 35KB
MethodBindingGenerator.cs 32KB
System_Runtime_CompilerServices_AsyncTaskMethodBuilder_1_Cor.cs 32KB
NetSerializer.cs 31KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
DefiningtheFuture
- 粉丝: 363
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功