Skip to content

Commit

Permalink
Supporting user-defined parameters for entry point in life. (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bing Duan authored and losfair committed Nov 18, 2018
1 parent 98065d8 commit 6bf6615
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ python3 run_spec_tests.py /path/to/testsuite
go build

# run your wasm program
./life /path/to/your/wasm/program.wasm # entry point is `app_main` with no arguments by default
# entry point is `app_main` by default if entry flag is omitted, array with
# param in it is optional arguements for entrypoint. params should be converted into `int`.
./life -entry 'method' /path/to/your/wasm/program.wasm [param,...]

```

## Executing WebAssembly Modules
Expand Down
12 changes: 11 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/perlin-network/life/exec"
"io/ioutil"
"strconv"
"time"
)

Expand Down Expand Up @@ -97,9 +98,18 @@ func main() {
panic(err)
}
}
var args []int64
for _, arg := range flag.Args()[1:] {
fmt.Println(arg)
if ia, err := strconv.Atoi(arg); err != nil {
panic(err)
} else {
args = append(args, int64(ia))
}
}

// Run the WebAssembly module's entry function.
ret, err := vm.Run(entryID)
ret, err := vm.Run(entryID, args...)
if err != nil {
vm.PrintStackTrace()
panic(err)
Expand Down

0 comments on commit 6bf6615

Please sign in to comment.