Skip to content

Commit

Permalink
[Examples] Move the examples in the tools into the examples.
Browse files Browse the repository at this point in the history
Signed-off-by: YiYing He <[email protected]>
  • Loading branch information
q82419 authored and hydai committed May 23, 2022
1 parent c6cdd71 commit c6dfa12
Show file tree
Hide file tree
Showing 38 changed files with 102 additions and 108 deletions.
4 changes: 2 additions & 2 deletions bindings/rust/wasmedge-sdk/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ mod tests {
assert!(result.is_ok());

// add a wasm module from a file
let file = std::path::PathBuf::from(env!("WASMEDGE_DIR"))
.join("tools/wasmedge/examples/fibonacci.wasm");
let file =
std::path::PathBuf::from(env!("WASMEDGE_DIR")).join("examples/wasm/fibonacci.wasm");
let result = Module::from_file(Some(&config), file);
assert!(result.is_ok());
let module = result.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions bindings/rust/wasmedge-sdk/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ mod tests {
assert!(result.is_ok());

// add a wasm module from a file
let file = std::path::PathBuf::from(env!("WASMEDGE_DIR"))
.join("tools/wasmedge/examples/fibonacci.wasm");
let file =
std::path::PathBuf::from(env!("WASMEDGE_DIR")).join("examples/wasm/fibonacci.wasm");
let result = Module::from_file(Some(&config), file);
assert!(result.is_ok());
let module = result.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions docs/book/en/src/embed/c.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The WasmEdge C API also the fundamental API for other languages' SDK.
## Quick Start Guide for the WasmEdge runner

The following is an example for running a WASM file.
Assume that the WASM file [fibonacci.wasm](https://github.com/WasmEdge/WasmEdge/raw/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and the C file `test_wasmedge.c` is as following:
Assume that the WASM file [fibonacci.wasm](https://github.com/WasmEdge/WasmEdge/raw/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and the C file `test_wasmedge.c` is as following:

```c
#include <wasmedge/wasmedge.h>
Expand Down Expand Up @@ -52,7 +52,7 @@ Get result: 3524578

## Quick Start Guide for the WasmEdge AOT compiler

Assume that the WASM file [fibonacci.wasm](https://github.com/WasmEdge/WasmEdge/raw/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and the C file `test_wasmedge_compiler.c` is as following:
Assume that the WASM file [fibonacci.wasm](https://github.com/WasmEdge/WasmEdge/raw/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and the C file `test_wasmedge_compiler.c` is as following:

```c
#include <wasmedge/wasmedge.h>
Expand Down
14 changes: 7 additions & 7 deletions docs/book/en/src/embed/c/0.9.1/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ In this partition, we will introduce the functions of `WasmEdge_VMContext` objec
### WASM Execution Example With VM Context
The following shows the example of running the WASM for getting the Fibonacci.
This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wat).
This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wat).
```wasm
(module
Expand All @@ -677,7 +677,7 @@ This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdg
1. Run WASM functions rapidly
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
```c
#include <wasmedge/wasmedge.h>
Expand Down Expand Up @@ -933,7 +933,7 @@ WasmEdge VM provides APIs for developers to register and export any WASM modules
1. Register the WASM modules with exported module names
Unless the import objects have already contained the module names, every WASM module should be named uniquely when registering.
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory.
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory.
```c
WasmEdge_VMContext *VMCxt = WasmEdge_VMCreate(NULL, NULL);
Expand Down Expand Up @@ -1016,7 +1016,7 @@ WasmEdge VM provides APIs for developers to register and export any WASM modules
1. Asynchronously run WASM functions rapidly
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
```c
#include <wasmedge/wasmedge.h>
Expand Down Expand Up @@ -1186,7 +1186,7 @@ The `VM` context supplies the APIs to retrieve the instances.
After the WASM module instantiation, developers can use the `WasmEdge_VMExecute()` API to invoke the exported WASM functions. For this purpose, developers may need information about the exported WASM function list.
Please refer to the [Instances in runtime](#instances) for the details about the function types.
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
```c
#include <wasmedge/wasmedge.h>
Expand Down Expand Up @@ -1264,7 +1264,7 @@ In this partition, we will introduce the objects of WasmEdge runtime manually.
### WASM Execution Example Step-By-Step
Besides the WASM execution through the [`VM` context](#wasmedge-vm), developers can execute the WASM functions or instantiate WASM modules step-by-step with the `Loader`, `Validator`, `Executor`, and `Store` contexts.
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
```c
#include <wasmedge/wasmedge.h>
Expand Down Expand Up @@ -2153,7 +2153,7 @@ The WasmEdge AOT (ahead-of-time) compiler compiles the WASM files for running in
### Compilation Example
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
```c
#include <wasmedge/wasmedge.h>
Expand Down
4 changes: 2 additions & 2 deletions docs/book/en/src/embed/c/0.9.1/upgrade_to_0.10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ WasmEdge_StringDelete(GlobName);

4. WASM function invokation

This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wat).
This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wat).
In WasmEdge `0.9.1` version, developers can invoke a WASM function with the export function name:

```c
Expand Down Expand Up @@ -348,7 +348,7 @@ WasmEdge_StringDelete(GlobName);

## Instances retrievement

This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wat).
This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wat).

Before the WasmEdge `0.9.1` versions, developers can retrieve all exported instances of named or anonymous modules from `Store`:

Expand Down
14 changes: 7 additions & 7 deletions docs/book/en/src/embed/c/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ In this partition, we will introduce the functions of `WasmEdge_VMContext` objec
### WASM Execution Example With VM Context
The following shows the example of running the WASM for getting the Fibonacci.
This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wat).
This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wat).
```wasm
(module
Expand All @@ -692,7 +692,7 @@ This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdg
1. Run WASM functions rapidly
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
```c
#include <wasmedge/wasmedge.h>
Expand Down Expand Up @@ -951,7 +951,7 @@ WasmEdge VM provides APIs for developers to register and export any WASM modules
1. Register the WASM modules with exported module names
Unless the module instances have already contained the module names, every WASM module should be named uniquely when registering.
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory.
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory.
```c
WasmEdge_VMContext *VMCxt = WasmEdge_VMCreate(NULL, NULL);
Expand Down Expand Up @@ -1034,7 +1034,7 @@ WasmEdge VM provides APIs for developers to register and export any WASM modules
1. Asynchronously run WASM functions rapidly
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
```c
#include <wasmedge/wasmedge.h>
Expand Down Expand Up @@ -1204,7 +1204,7 @@ The `VM` context supplies the APIs to retrieve the instances.
After the WASM module instantiation, developers can use the `WasmEdge_VMExecute()` API to invoke the exported WASM functions. For this purpose, developers may need information about the exported WASM function list.
Please refer to the [Instances in runtime](#instances) for the details about the function types.
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
```c
#include <wasmedge/wasmedge.h>
Expand Down Expand Up @@ -1301,7 +1301,7 @@ In this partition, we will introduce the objects of WasmEdge runtime manually.
### WASM Execution Example Step-By-Step
Besides the WASM execution through the [`VM` context](#wasmedge-vm), developers can execute the WASM functions or instantiate WASM modules step-by-step with the `Loader`, `Validator`, `Executor`, and `Store` contexts.
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
```c
#include <wasmedge/wasmedge.h>
Expand Down Expand Up @@ -2249,7 +2249,7 @@ The WasmEdge AOT (ahead-of-time) compiler compiles the WASM files for running in
### Compilation Example
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and the C file `test.c` is as following:
```c
#include <wasmedge/wasmedge.h>
Expand Down
10 changes: 5 additions & 5 deletions docs/book/en/src/embed/go/0.9.1/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ In this partition, we will introduce the functions of `wasmedge.VM` object and s
### WASM Execution Example With VM Object
The following shows the example of running the WASM for getting the Fibonacci.
This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wat).
This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wat).
```wasm
(module
Expand Down Expand Up @@ -875,7 +875,7 @@ This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdg
go mod init wasmedge_test
```
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current `wasmedge_test` directory, and create and edit the Go file `main.go` as following:
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current `wasmedge_test` directory, and create and edit the Go file `main.go` as following:
```go
package main
Expand Down Expand Up @@ -1138,7 +1138,7 @@ WasmEdge VM provides APIs for developers to register and export any WASM modules
go mod init wasmedge_test
```
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory.
Assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory.
Then create and edit the Go file `main.go` as following:
```go
Expand Down Expand Up @@ -1262,7 +1262,7 @@ The `VM` object supplies the APIs to retrieve the instances.
go mod init wasmedge_test
```
Then assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and create and edit a Go file `main.go`:
Then assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and create and edit a Go file `main.go`:
```go
package main
Expand Down Expand Up @@ -1352,7 +1352,7 @@ mkdir wasmedge_test && cd wasmedge_test
go mod init wasmedge_test
```
Then assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm) is copied into the current directory, and create and edit a Go file `main.go`:
Then assume that the WASM file [`fibonacci.wasm`](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm) is copied into the current directory, and create and edit a Go file `main.go`:
```go
package main
Expand Down
4 changes: 2 additions & 2 deletions docs/book/en/src/embed/go/0.9.1/upgrade_to_0.10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ globinst := mod.FindGlobal("global_i32")

4. WASM function invokation

This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wat).
This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wat).
In WasmEdge-Go `v0.9.2` version, developers can invoke a WASM function with the export function name:

```go
Expand Down Expand Up @@ -333,7 +333,7 @@ globinst := mod.FindGlobal("global_i32")

## Instances retrievement

This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/tools/wasmedge/examples/fibonacci.wat).
This example uses the [fibonacci.wasm](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wasm), and the corresponding WAT file is at [fibonacci.wat](https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/examples/wasm/fibonacci.wat).

Before the WasmEdge-Go `v0.9.2` versions, developers can retrieve all exported instances of named or anonymous modules from `Store`:

Expand Down
Loading

0 comments on commit c6dfa12

Please sign in to comment.