| 1 | package Wasm::Wasmtime::FuncType; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 26 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 26 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 26 | ▶ | use 5.008004; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 26 | ▶ | use base qw( Wasm::Wasmtime::ExternType ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 26 | ▶ | use Ref::Util qw( is_arrayref ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 26 | ▶ | use Wasm::Wasmtime::FFI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 26 | ▶ | use Wasm::Wasmtime::ValType; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 26 | ▶ | use constant is_functype => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 26 | ▶ | use constant kind => 'functype'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # ABSTRACT: Wasmtime function type class | ||||||||||||||||||||||||||||
| 14 | 26 | our $VERSION = '0.24'; # VERSION | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 26 | $ffi_prefix = 'wasm_functype_'; | |||||||||||||||||||||||||||
| 18 | 26 | $ffi->load_custom_type('::PtrObject' => 'wasm_functype_t' => __PACKAGE__); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 10 | ▶ | $ffi->attach( new => ['wasm_valtype_vec_t*', 'wasm_valtype_vec_t*'] => 'wasm_functype_t' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.6
| |||||||||||||||||||||||||||||
| 22 | 10 | my $xsub = shift; | |||||||||||||||||||||||||||
| 23 | 10 | my $class = shift; | |||||||||||||||||||||||||||
| 24 | 10 | ▶ | if(is_arrayref $_[0] && is_arrayref $_[1]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
is_arrayref($_[0]) and is_arrayref($_[1])
MC/DC0%0/2
is_arrayref($_[0]) and is_arrayref($_[1])
is_arrayref($_[0])
is_arrayref($_[1])
Truth table33%1/3
A and B
A= is_arrayref($_[0])B= is_arrayref($_[1])
| |||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||
| 26 | # try not to think too much about all of the maps here | ||||||||||||||||||||||||||||
| 27 | 20 | my($params, $results) = map { my $rec = Wasm::Wasmtime::ValTypeVec->new; $rec->set($_) } | |||||||||||||||||||||||||||
| 28 | 10 | map { [map { delete $_->{ptr} } map { Wasm::Wasmtime::ValType->new($_) } @$_] } @_; | |||||||||||||||||||||||||||
| 29 | 10 | my $self = $xsub->($params, $results); | |||||||||||||||||||||||||||
| 30 | 10 | return $self; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | else | ||||||||||||||||||||||||||||
| 33 | { | ||||||||||||||||||||||||||||
| 34 | 0 | my($ptr, $owner) = @_; | |||||||||||||||||||||||||||
| 35 | 0 | bless { | |||||||||||||||||||||||||||
| 36 | ptr => $ptr, | ||||||||||||||||||||||||||||
| 37 | owner => $owner, | ||||||||||||||||||||||||||||
| 38 | }, $class; | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 26 | }); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 78 | ▶ | $ffi->attach( params => ['wasm_functype_t'] => 'wasm_valtype_vec_t*' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | 78 | my($xsub, $self) = @_; | |||||||||||||||||||||||||||
| 45 | 78 | $xsub->($self)->to_list; | |||||||||||||||||||||||||||
| 46 | 26 | }); | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 76 | ▶ | $ffi->attach( results => ['wasm_functype_t'] => 'wasm_valtype_vec_t*' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 50 | 76 | my($xsub, $self) = @_; | |||||||||||||||||||||||||||
| 51 | 76 | $xsub->($self)->to_list; | |||||||||||||||||||||||||||
| 52 | 26 | }); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | sub to_string | ||||||||||||||||||||||||||||
| 56 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
to_string: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 5 | my($self) = @_; | |||||||||||||||||||||||||||
| 58 | 5 | my @params = map { $_->to_string } $self->params; | |||||||||||||||||||||||||||
| 59 | 5 | my @results = map { $_->to_string } $self->results; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 5 | my $string = ''; | |||||||||||||||||||||||||||
| 62 | 5 | ▶ | $string .= "(param @params)" if @params; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 5 | ▶ | $string .= ' ' if $string && @results; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$string and @results
MC/DC50%1/2
$string and @results
$string
@results
Truth table66%2/3
A and B
A= $stringB= @results
| |||||||||||||||||||||||||||||
| 64 | 5 | ▶ | $string .= "(result @results)" if @results; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 5 | $string; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 26 | __PACKAGE__->_cast(0); | |||||||||||||||||||||||||||
| 69 | 26 | _generate_destroy(); | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 26 | 1; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | __END__ | ||||||||||||||||||||||||||||