rm
This commit is contained in:
12
deno_run_wasm/run_wasm.ts
Normal file
12
deno_run_wasm/run_wasm.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
const wasmCode = await Deno.readFile("./target/wasm32-unknown-unknown/debug/wasm_deno_example.wasm");
|
||||||
|
const wasmModule = new WebAssembly.Module(wasmCode);
|
||||||
|
const wasmInstance = new WebAssembly.Instance(wasmModule);
|
||||||
|
const {
|
||||||
|
square,
|
||||||
|
} = wasmInstance.exports;
|
||||||
|
|
||||||
|
console.log(square(1));
|
||||||
|
console.log(square(2));
|
||||||
|
console.log(square(3));
|
||||||
|
console.log(square(4));
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
5
deno_run_wasm/wasm_sample/Cargo.lock
generated
Normal file
5
deno_run_wasm/wasm_sample/Cargo.lock
generated
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "warsam_sample"
|
||||||
|
version = "0.1.0"
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "warsam_sample"
|
name = "wasm_sample"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type =["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
1
deno_run_wasm/wasm_sample/build.sh
Normal file
1
deno_run_wasm/wasm_sample/build.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cargo build --target wasm32-unknown-unknown
|
||||||
4
deno_run_wasm/wasm_sample/src/lib.rs
Normal file
4
deno_run_wasm/wasm_sample/src/lib.rs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn square(x: u32) -> u32 {
|
||||||
|
x * x
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user