line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::FuncType; |
2
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
232028
|
use strict; |
|
26
|
|
|
|
|
62
|
|
|
26
|
|
|
|
|
801
|
|
4
|
26
|
|
|
26
|
|
145
|
use warnings; |
|
26
|
|
|
|
|
63
|
|
|
26
|
|
|
|
|
575
|
|
5
|
26
|
|
|
26
|
|
409
|
use 5.008004; |
|
26
|
|
|
|
|
120
|
|
6
|
26
|
|
|
26
|
|
175
|
use base qw( Wasm::Wasmtime::ExternType ); |
|
26
|
|
|
|
|
62
|
|
|
26
|
|
|
|
|
7926
|
|
7
|
26
|
|
|
26
|
|
211
|
use Ref::Util qw( is_arrayref ); |
|
26
|
|
|
|
|
96
|
|
|
26
|
|
|
|
|
1207
|
|
8
|
26
|
|
|
26
|
|
168
|
use Wasm::Wasmtime::FFI; |
|
26
|
|
|
|
|
55
|
|
|
26
|
|
|
|
|
2535
|
|
9
|
26
|
|
|
26
|
|
5277
|
use Wasm::Wasmtime::ValType; |
|
26
|
|
|
|
|
87
|
|
|
26
|
|
|
|
|
816
|
|
10
|
26
|
|
|
26
|
|
159
|
use constant is_functype => 1; |
|
26
|
|
|
|
|
62
|
|
|
26
|
|
|
|
|
1636
|
|
11
|
26
|
|
|
26
|
|
179
|
use constant kind => 'functype'; |
|
26
|
|
|
|
|
69
|
|
|
26
|
|
|
|
|
14962
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Wasmtime function type class |
14
|
|
|
|
|
|
|
our $VERSION = '0.23'; # 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
|
144
|
my($self) = @_; |
58
|
5
|
|
|
|
|
23
|
my @params = map { $_->to_string } $self->params; |
|
9
|
|
|
|
|
110
|
|
59
|
5
|
|
|
|
|
66
|
my @results = map { $_->to_string } $self->results; |
|
5
|
|
|
|
|
85
|
|
60
|
|
|
|
|
|
|
|
61
|
5
|
|
|
|
|
69
|
my $string = ''; |
62
|
5
|
100
|
|
|
|
59
|
$string .= "(param @params)" if @params; |
63
|
5
|
100
|
66
|
|
|
36
|
$string .= ' ' if $string && @results; |
64
|
5
|
100
|
|
|
|
26
|
$string .= "(result @results)" if @results; |
65
|
5
|
|
|
|
|
37
|
$string; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__PACKAGE__->_cast(0); |
69
|
|
|
|
|
|
|
_generate_destroy(); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |