line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::FuncType; |
2
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
233606
|
use strict; |
|
26
|
|
|
|
|
72
|
|
|
26
|
|
|
|
|
784
|
|
4
|
26
|
|
|
26
|
|
138
|
use warnings; |
|
26
|
|
|
|
|
59
|
|
|
26
|
|
|
|
|
616
|
|
5
|
26
|
|
|
26
|
|
453
|
use 5.008004; |
|
26
|
|
|
|
|
111
|
|
6
|
26
|
|
|
26
|
|
163
|
use base qw( Wasm::Wasmtime::ExternType ); |
|
26
|
|
|
|
|
69
|
|
|
26
|
|
|
|
|
7848
|
|
7
|
26
|
|
|
26
|
|
193
|
use Ref::Util qw( is_arrayref ); |
|
26
|
|
|
|
|
84
|
|
|
26
|
|
|
|
|
1239
|
|
8
|
26
|
|
|
26
|
|
172
|
use Wasm::Wasmtime::FFI; |
|
26
|
|
|
|
|
62
|
|
|
26
|
|
|
|
|
2778
|
|
9
|
26
|
|
|
26
|
|
5295
|
use Wasm::Wasmtime::ValType; |
|
26
|
|
|
|
|
105
|
|
|
26
|
|
|
|
|
831
|
|
10
|
26
|
|
|
26
|
|
170
|
use constant is_functype => 1; |
|
26
|
|
|
|
|
56
|
|
|
26
|
|
|
|
|
1711
|
|
11
|
26
|
|
|
26
|
|
209
|
use constant kind => 'functype'; |
|
26
|
|
|
|
|
58
|
|
|
26
|
|
|
|
|
15172
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Wasmtime function type class |
14
|
|
|
|
|
|
|
our $VERSION = '0.22'; # VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$ffi_prefix = 'wasm_functype_'; |
18
|
|
|
|
|
|
|
$ffi->load_custom_type('::PtrObject' => 'wasm_functype_t' => __PACKAGE__); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$ffi->attach( new => ['wasm_valtype_vec_t*', 'wasm_valtype_vec_t*'] => 'wasm_functype_t' => sub { |
22
|
|
|
|
|
|
|
my $xsub = shift; |
23
|
|
|
|
|
|
|
my $class = shift; |
24
|
|
|
|
|
|
|
if(is_arrayref $_[0] && is_arrayref $_[1]) |
25
|
|
|
|
|
|
|
{ |
26
|
|
|
|
|
|
|
# try not to think too much about all of the maps here |
27
|
|
|
|
|
|
|
my($params, $results) = map { my $rec = Wasm::Wasmtime::ValTypeVec->new; $rec->set($_) } |
28
|
|
|
|
|
|
|
map { [map { delete $_->{ptr} } map { Wasm::Wasmtime::ValType->new($_) } @$_] } @_; |
29
|
|
|
|
|
|
|
my $self = $xsub->($params, $results); |
30
|
|
|
|
|
|
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
my($ptr, $owner) = @_; |
35
|
|
|
|
|
|
|
bless { |
36
|
|
|
|
|
|
|
ptr => $ptr, |
37
|
|
|
|
|
|
|
owner => $owner, |
38
|
|
|
|
|
|
|
}, $class; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
}); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$ffi->attach( params => ['wasm_functype_t'] => 'wasm_valtype_vec_t*' => sub { |
44
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
45
|
|
|
|
|
|
|
$xsub->($self)->to_list; |
46
|
|
|
|
|
|
|
}); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$ffi->attach( results => ['wasm_functype_t'] => 'wasm_valtype_vec_t*' => sub { |
50
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
51
|
|
|
|
|
|
|
$xsub->($self)->to_list; |
52
|
|
|
|
|
|
|
}); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub to_string |
56
|
|
|
|
|
|
|
{ |
57
|
5
|
|
|
5
|
1
|
201
|
my($self) = @_; |
58
|
5
|
|
|
|
|
27
|
my @params = map { $_->to_string } $self->params; |
|
9
|
|
|
|
|
108
|
|
59
|
5
|
|
|
|
|
71
|
my @results = map { $_->to_string } $self->results; |
|
5
|
|
|
|
|
27
|
|
60
|
|
|
|
|
|
|
|
61
|
5
|
|
|
|
|
64
|
my $string = ''; |
62
|
5
|
100
|
|
|
|
48
|
$string .= "(param @params)" if @params; |
63
|
5
|
100
|
66
|
|
|
34
|
$string .= ' ' if $string && @results; |
64
|
5
|
100
|
|
|
|
33
|
$string .= "(result @results)" if @results; |
65
|
5
|
|
|
|
|
62
|
$string; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__PACKAGE__->_cast(0); |
69
|
|
|
|
|
|
|
_generate_destroy(); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |