| 1 | package Wasm::Wasm3::Runtime; | ||
| 2 | |||
| 3 | 4 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 4 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | =encoding utf-8 | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Wasm::Wasm3::Runtime | ||
| 11 | |||
| 12 | =head1 SYNOPSIS | ||
| 13 | |||
| 14 | See L<Wasm::Wasm3>. | ||
| 15 | |||
| 16 | =head1 DESCRIPTION | ||
| 17 | |||
| 18 | This module exposes L<wasm3|https://github.com/wasm3/wasm3>’s | ||
| 19 | runtime object to Perl. | ||
| 20 | |||
| 21 | =cut | ||
| 22 | |||
| 23 | #---------------------------------------------------------------------- | ||
| 24 | |||
| 25 | 4 | ▶ | use Wasm::Wasm3; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 26 | |||
| 27 | #---------------------------------------------------------------------- | ||
| 28 | |||
| 29 | =head1 METHODS | ||
| 30 | |||
| 31 | This class is not directly instantiated; see L<Wasm::Wasm3> for | ||
| 32 | details. | ||
| 33 | |||
| 34 | =head2 $obj = I<OBJ>->load_module( $MODULE_OBJ ) | ||
| 35 | |||
| 36 | Loads a parsed module (i.e., L<Wasm::Wasm3::Module> instance). | ||
| 37 | Returns I<OBJ>. | ||
| 38 | |||
| 39 | =head2 @returns = I<OBJ>->call( $FUNCTION_NAME, @ARGUMENTS ) | ||
| 40 | |||
| 41 | Calls the named function with the given arguments, returning the | ||
| 42 | returns from that function. | ||
| 43 | |||
| 44 | A scalar-context call to this method will produce an exception | ||
| 45 | if the WebAssembly function returns multiple values. | ||
| 46 | |||
| 47 | =head2 $exit_code = I<OBJ>->run_wasi( @ARGV ) | ||
| 48 | |||
| 49 | A WASI-specific variant of C<call()>. Calls WASI’s start function | ||
| 50 | (as of this writing, always C<_start>) with the given @ARGV list | ||
| 51 | (byte strings). | ||
| 52 | |||
| 53 | Returns the WASI exit code. | ||
| 54 | |||
| 55 | =head2 @types = I<OBJ>->get_function_arguments( $FUNCTION_NAME ) | ||
| 56 | |||
| 57 | Returns a list of the named function’s argument types, as TYPE_* constants. | ||
| 58 | (cf. L<Wasm::Wasm3>) | ||
| 59 | |||
| 60 | =head2 @types = I<OBJ>->get_function_returns( $FUNCTION_NAME ) | ||
| 61 | |||
| 62 | Like C<get_function_arguments()> but for return types. | ||
| 63 | |||
| 64 | =head2 $str = I<OBJ>->get_memory( [ $OFFSET [, $WANTLENGTH] ] ) | ||
| 65 | |||
| 66 | Fetches all or part of I<OBJ>’s WebAssembly memory buffer as a byte string. | ||
| 67 | $OFFSET defaults to 0, and $WANTLENGTH defaults to the buffer’s length less | ||
| 68 | $OFFSET. If $WANTLENGTH + $OFFSET exceed the buffer’s size, the returned | ||
| 69 | string will contain just the content from $OFFSET to the buffer’s end. | ||
| 70 | |||
| 71 | Currently both values B<MUST> be nonnegative. | ||
| 72 | |||
| 73 | =head2 $count = I<OBJ>->get_memory_size() | ||
| 74 | |||
| 75 | Returns the size, in bytes of I<OBJ>’s WebAssembly memory buffer. | ||
| 76 | |||
| 77 | =head2 $obj = I<OBJ>->set_memory( $OFFSET, $NEW_BYTES ) | ||
| 78 | |||
| 79 | Overwrites all or part of I<OBJ>’s WebAssembly memory buffer with | ||
| 80 | $NEW_BYTES. Returns I<OBJ>. | ||
| 81 | |||
| 82 | =cut | ||
| 83 | |||
| 84 | 4 | 1; | |