line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::ValType; |
2
|
|
|
|
|
|
|
|
3
|
27
|
|
|
27
|
|
190708
|
use strict; |
|
27
|
|
|
|
|
60
|
|
|
27
|
|
|
|
|
775
|
|
4
|
27
|
|
|
27
|
|
153
|
use warnings; |
|
27
|
|
|
|
|
65
|
|
|
27
|
|
|
|
|
585
|
|
5
|
27
|
|
|
27
|
|
397
|
use 5.008004; |
|
27
|
|
|
|
|
87
|
|
6
|
27
|
|
|
27
|
|
535
|
use Wasm::Wasmtime::FFI; |
|
27
|
|
|
|
|
72
|
|
|
27
|
|
|
|
|
13137
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Wasmtime value type class |
9
|
|
|
|
|
|
|
our $VERSION = '0.21'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$ffi_prefix = 'wasm_valtype_'; |
13
|
|
|
|
|
|
|
$ffi->load_custom_type('::PtrObject' => 'wasm_valtype_t' => __PACKAGE__); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my %kind = ( |
16
|
|
|
|
|
|
|
0 => 'i32', |
17
|
|
|
|
|
|
|
1 => 'i64', |
18
|
|
|
|
|
|
|
2 => 'f32', |
19
|
|
|
|
|
|
|
3 => 'f64', |
20
|
|
|
|
|
|
|
128 => 'anyref', |
21
|
|
|
|
|
|
|
129 => 'funcref', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my %rkind; |
25
|
|
|
|
|
|
|
foreach my $key (keys %kind) |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
my $value = $kind{$key}; |
28
|
|
|
|
|
|
|
$rkind{$value} = $key; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$ffi->attach( new => ['uint8'] => 'wasm_valtype_t' => sub { |
33
|
|
|
|
|
|
|
my $xsub = shift; |
34
|
|
|
|
|
|
|
my $class = shift; |
35
|
|
|
|
|
|
|
if($_[0] =~ /^[0-9]+$/) |
36
|
|
|
|
|
|
|
{ |
37
|
|
|
|
|
|
|
my($ptr, $owner) = @_; |
38
|
|
|
|
|
|
|
return bless { |
39
|
|
|
|
|
|
|
ptr => $ptr, |
40
|
|
|
|
|
|
|
owner => $owner, |
41
|
|
|
|
|
|
|
}, $class; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
my($kind) = @_; |
46
|
|
|
|
|
|
|
my $kind_num = $rkind{$kind}; |
47
|
|
|
|
|
|
|
Carp::croak("no such value type: $kind") unless defined $kind_num; |
48
|
|
|
|
|
|
|
return $xsub->($kind_num); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
}); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
131
|
|
|
131
|
1
|
25156
|
sub kind { $kind{shift->kind_num} } |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$ffi->attach( [kind => 'kind_num'] => ['wasm_valtype_t'] => 'uint8' ); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
*to_string = \&kind; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
_generate_destroy(); |
62
|
|
|
|
|
|
|
_generate_vec_class( delete => 0 ); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$ffi->attach( [ wasm_valtype_vec_new => 'Wasm::Wasmtime::ValTypeVec::set' ] => ['wasm_valtype_vec_t*','size_t','opaque[]'] => sub { |
65
|
|
|
|
|
|
|
my($xsub, $self, $valtypes) = @_; |
66
|
|
|
|
|
|
|
$xsub->($self, scalar(@$valtypes), $valtypes); |
67
|
|
|
|
|
|
|
$self; |
68
|
|
|
|
|
|
|
}); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |