Skip to content

Files

Latest commit

author
null
Jun 16, 2019
23cadc6 · Jun 16, 2019

History

History
This branch is 9 commits ahead of, 405 commits behind WebAssembly/WASI:main.

schema

WASI Interface Definitions

The interface definition are written in Capn Proto schema.

Files

Cap'n Proto Wasm Generation

Multiple Returns

Multiple returns in Cap'n Proto schema should be translated into pointer arguments that is appended to the end of a function arguments. For example

returnTwoInts @0 (
  someInput :Uint64
) -> (
  first :UInt64,
  second :Uint64
);

Would get compiled to the following signature

(func $returnTwoInts 
  (param $someInput i64)
  (param $ptr_first i32)
  (param $ptr_second i32)
)

Returned Text

Text as an return value is turned into two arguments a pointer to write the text and an i32 representing the length of memory allocated for storing the text.

returnString @0 (
  someInput :Uint64
) -> (
  path :Text
);

Would get compiled to the following signature

(func $returnString 
  (param $someInput i64)
  (param $ptr_path i32)
  (param $path_len i32)
)

Lists

Lists are turned into a pointer to a buffer of pointers

get @0 (
  args :List(Text) # the environment variables string data.
) -> ()

Would get compiled to the following signature

(func $returnString 
  (param $argv i32)
  (param $argv_buf i32)
)