The system interface defines which imports are avaible to webassembly programs running inside Primea.
We define the following types:
i32
: same asi32
in WebAssemblyi32ptr
: same asi32
in WebAssembly, but treated as a pointer to a WebAssembly memory offseti32ref
: same asi32
in WebAssembly, but treated as a reference to a Primea object
Messages can contain data which is read from memory starting at the offset
and going for len
bytes.
Parameters
offset
i32ptr - a pointer to the location in memory to start reading fromlen
i32 - the number of bytes to read starting fromoffset
Returns
- i32ref the refence to a the message
Creates a channel and writes two port references to memory. Each port reference
is an i32
Parameters
locA
i32ptrlocB
i32ptr
Assigns a byte array to a port and starts to listen for incoming messages on it. The byte array is used as a name to retrieve the port in the future.
Parameters
offset
i32ptr - a pointer to the location in memory to start reading fromlen
i32 - the number of bytes to read starting fromoffset
portRef
i32ref - the reference to the port being bounded
Stops listening to a port and returns a reference to the port
Parameters
offset
i32ptr - a pointer to the location in memory to start reading fromlen
i32 - the number of bytes to read starting fromoffset
Returns
- i32ref - the referance to the port being unbounded
Given the port's name this returns a refernce to the port.
Parameters
offset
i32ptr - a pointer to the location in memory to start reading fromlen
i32 - the number of bytes to read starting fromoffset
Returns
- i32ref - the reference to the port being unbounded
Gets the number of bytes contain in the message's data payload
Parameters
message
i32ref - the reference to the message
Returns
- i32
Loads the message's data into memory
Parameters
message
i32ref - the reference to the messagewriteOffset
i32ptrreadOffset
i32ptrlen
i32
Add a port ref to a message
Parameters
message
i32ref - the reference to the messageport
i32ref - the reference to the port
Gets the number of ports contained in the message
Parameters
message
i32ref - the reference to the message
Returns
- i32
Gets a port reference from a given message
Parameters
message
i32ref - the reference to the messageindex
i32 which port to in the message to load. The same port cannot be loaded twice
Returns
- i32ref
sends a message on a given port
Parameters
message
i32ref - the reference to the messageport
i32ref - the reference to the port
test is an i32 is a valid ref or not
Parameters
message
i32ref
Returns
- i32
deletes a port or message refs
Parameters
message
i32ref