About WebAssembly
WebAssembly is a new way of encoding that can run in modern web browsers – it's a low-level class assembly language with a compact binary format that runs close to native performance and provides compilation targets for languages such as C/C++, C#, and Rust so that they can run on the web. It is also designed to coexist with JavaScript, allowing the two to work together.
Generate a test wasm file
AssemblyScript is a TypeScript-like WebAssembly language (The hyperlink login is visible.)。 Install the AssemblyScript tool, which compiles the typescript file into a WebAssembly file. The installation command is as follows:
Create a new test.ts file and define it as follows:
Generate the .wasm file with the following command:
Configuration parameters:The hyperlink login is visible.
Execute the functions within wasm
Method 1 (Easiest)
Directly reference the generated .js module execution, as follows:
Method 2
With assemblyscript/loader, reference:The hyperlink login is visible., the code is as follows:
The .wasm command can be generated in this way as follows:
This way it doesn't generate .ts, . js file.
Method 3
Load compilation using native WebAssembly, the code is as follows:
Finally, attach the source code file:
Tourists, if you want to see the hidden content of this post, please Reply
|