YAMAMOTO Takashi 37b09d0f24 Expose wasm_runtime_call_indirect (#1969) 2 năm trước cách đây
..
src 37b09d0f24 Expose wasm_runtime_call_indirect (#1969) 2 năm trước cách đây
wasm-apps 3ded9ece83 Apply clang format for samples files (#833) 4 năm trước cách đây
.gitignore 5e196253f6 Fix function type not set issue of aot_call_indirect (#229) 5 năm trước cách đây
CMakeLists.txt 654ac5feca Use cmake POSITION_INDEPENDENT_CODE instead of hardcoding -pie -fPIE (#1598) 3 năm trước cách đây
README.md 5d86060d35 fix one typo in samples/basic.README.md (#274) 5 năm trước cách đây
build.sh bb87180b72 Update document and fix wasm_runtime_call_wasm_a issue (#1005) 3 năm trước cách đây
run.sh 67495919b0 Add a basic sample to show how native runtime invokes wasm apps in WAMR and how wasm apps invoke native functions. (#207) 5 năm trước cách đây

README.md

The "basic" sample project

This sample demonstrates a few basic usages of embedding WAMR:

  • initialize runtime
  • load wasm app and instantiate the module
  • call wasm function and pass arguments
  • export native functions to the WASM apps
  • wasm function calls native function and pass arguments
  • deinitialize runtime

Build this sample

Execute the build.sh script then all binaries including wasm application files would be generated in 'out' directory.

$ ./build.sh

Run the sample

Enter the out directory.

$ cd ./out/
$
$ ./basic -f wasm-apps/testapp.wasm
calling into WASM function: generate_float
Native finished calling wasm function generate_float(), returned a float value: 102009.921875f
calling into WASM function: float_to_string
calling into native function: intToStr
calling into native function: get_pow
calling into native function: intToStr
Native finished calling wasm function: float_to_string, returned a formatted string: 102009.921

Or execute the run.sh script in samples/basic folder.

$ ./run.sh
calling into WASM function: generate_float
Native finished calling wasm function generate_float(), returned a float value: 102009.921875f
calling into WASM function: float_to_string
calling into native function: intToStr
calling into native function: get_pow
calling into native function: intToStr
Native finished calling wasm function: float_to_string, returned a formatted  string: 102009.921