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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 课程作业-基于c#实现的反重力小游戏源码.zip课程作业-基于c#实现的反重力小游戏源码.zip课程作业-基于c#实现的反重力小游戏源码.zip课程作业-基于c#实现的反重力小游戏源码.zip课程作业-基于c#实现的反重力小游戏源码.zip课程作业-基于c#实现的反重力小游戏源码.zip课程作业-基于c#实现的反重力小游戏源码.zip课程作业-基于c#实现的反重力小游戏源码.zip课程作业-基于c#实现的反重力小游戏源码.zip课程作业-基于c#实现的反重力小游戏源码.zip课程作业-基于c#实现的反重力小游戏源码.zip 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载使用,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 欢迎下载,沟通交流,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
课程作业-基于c#实现的反重力小游戏源码.zip (1989个子文件)
Tips_HPTooLow.anim 11KB
Tips_LeaveObstacle.anim 11KB
Tips_TooFar.anim 11KB
Tips_GetBuff.anim 11KB
Tips_Goal.anim 11KB
Score_Down.anim 10KB
Score_Up.anim 10KB
Health_Down.anim 8KB
Level_Down.anim 8KB
Health_Up.anim 8KB
Level_Up.anim 8KB
Cam_Down.anim 7KB
Cam_Up.anim 5KB
Cam_Start.anim 4KB
Cam_Stay.anim 4KB
Player_Move.anim 1KB
Player_Normal.anim 1KB
Health_Normal.anim 1KB
Score_Normal.anim 1KB
Level_Normal.anim 1KB
Cam_Normal.anim 1KB
Tips_Null.anim 1KB
AssetCleaner.asmdef 343B
Mischief.MDV.Editor.asmdef 325B
CleanerStyle.asset 37KB
ProjectSettings.asset 24KB
InputManager.asset 10KB
Localization-String-Tables-English (en)_BundledAssetGroupSchema.asset 6KB
AddressableAssetSettings.asset 4KB
QualitySettings.asset 4KB
URP-HighFidelity-Renderer.asset 3KB
GraphicsSettings.asset 3KB
SampleSceneProfile.asset 2KB
URP-Balanced-Renderer.asset 2KB
URP-HighFidelity.asset 2KB
URP-Performant.asset 2KB
URP-Balanced.asset 2KB
Packed Assets.asset 2KB
Physics2DSettings.asset 2KB
URP-Performant-Renderer.asset 2KB
Localization-String-Tables-Chinese (Simplified) (zh-Hans)_BundledAssetGroupSchema.asset 2KB
Localization-Assets-Shared_BundledAssetGroupSchema.asset 2KB
Localization-Locales_BundledAssetGroupSchema.asset 2KB
Default Local Group_BundledAssetGroupSchema.asset 2KB
MiniGameConfig.asset 2KB
Localization-String-Tables-Chinese (Simplified) (zh-Hans).asset 1KB
Localization-String-Tables-English (en).asset 1KB
Localization-Assets-Shared.asset 1KB
EditorSettings.asset 1KB
NavMeshAreas.asset 1KB
DynamicsManager.asset 1KB
MemorySettings.asset 1KB
Readme.asset 1KB
Localization-Locales.asset 1KB
UnityConnectSettings.asset 1005B
Built In Data.asset 929B
PackageManagerSettings.asset 928B
UniversalRenderPipelineGlobalSettings.asset 842B
Default Local Group.asset 822B
BuildScriptPackedPlayMode.asset 816B
BuildScriptVirtualMode.asset 813B
BuildScriptPackedMode.asset 812B
BuildScriptFastMode.asset 810B
Parent Data 03 Challenge.asset 626B
Parent Data 02 Hard.asset 625B
Parent Data 01 Easy.asset 618B
SpecialObstacleData.asset 582B
Circle Debuff Data.asset 581B
EditorBuildSettings.asset 578B
Circle Buff Data.asset 578B
TagManager.asset 577B
SpecialPropData.asset 576B
Circle Prop Data.asset 573B
Localization-String-Tables-Chinese (Simplified) (zh-Hans)_ContentUpdateGroupSchema.asset 571B
Triangle Debuff Data.asset 570B
Square Debuff Data.asset 570B
Hexagon Debuff Data.asset 570B
Built In Data_PlayerDataGroupSchema.asset 568B
Square Buff Data.asset 567B
Square Prop Data.asset 567B
Triangle Buff Data.asset 565B
Hexagon Buff Data.asset 564B
Hexagon Prop Data.asset 564B
Triangle Prop Data.asset 564B
Player Data 02 Challenge.asset 559B
Player Data 01 Normal.asset 554B
Localization-String-Tables-English (en)_ContentUpdateGroupSchema.asset 553B
HeartData.asset 552B
StarData.asset 552B
Player Data Test.asset 548B
Localization-Assets-Shared_ContentUpdateGroupSchema.asset 540B
Localization-Locales_ContentUpdateGroupSchema.asset 534B
Default Local Group_ContentUpdateGroupSchema.asset 533B
Hexagon Data.asset 503B
Square Data.asset 502B
Circle Data.asset 500B
Triangle Data.asset 500B
DefaultObject.asset 469B
ShaderGraphSettings.asset 463B
TimelineSettings.asset 436B
共 1989 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
Make程序设计
- 粉丝: 5716
- 资源: 3570
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功