line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::ExternType; |
2
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
229561
|
use strict; |
|
26
|
|
|
|
|
62
|
|
|
26
|
|
|
|
|
711
|
|
4
|
26
|
|
|
26
|
|
131
|
use warnings; |
|
26
|
|
|
|
|
72
|
|
|
26
|
|
|
|
|
565
|
|
5
|
26
|
|
|
26
|
|
387
|
use 5.008004; |
|
26
|
|
|
|
|
89
|
|
6
|
26
|
|
|
26
|
|
2052
|
use Wasm::Wasmtime::FFI; |
|
26
|
|
|
|
|
62
|
|
|
26
|
|
|
|
|
4801
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Wasm::Wasmtime::FuncType; |
9
|
|
|
|
|
|
|
require Wasm::Wasmtime::GlobalType; |
10
|
|
|
|
|
|
|
require Wasm::Wasmtime::TableType; |
11
|
|
|
|
|
|
|
require Wasm::Wasmtime::MemoryType; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Wasmtime extern type class |
14
|
|
|
|
|
|
|
our $VERSION = '0.21'; # VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
1
|
0
|
sub kind { die "internal error" }; |
18
|
26
|
|
|
26
|
|
214
|
use constant is_functype => 0; |
|
26
|
|
|
|
|
125
|
|
|
26
|
|
|
|
|
1748
|
|
19
|
26
|
|
|
26
|
|
168
|
use constant is_globaltype => 0; |
|
26
|
|
|
|
|
56
|
|
|
26
|
|
|
|
|
1283
|
|
20
|
26
|
|
|
26
|
|
171
|
use constant is_tabletype => 0; |
|
26
|
|
|
|
|
63
|
|
|
26
|
|
|
|
|
1348
|
|
21
|
26
|
|
|
26
|
|
177
|
use constant is_memorytype => 0; |
|
26
|
|
|
|
|
93
|
|
|
26
|
|
|
|
|
8315
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$ffi_prefix = 'wasm_externtype_'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$ffi->attach( [ kind => '_kind' ] => ['opaque'] => 'uint8' ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my @cast; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _cast |
30
|
|
|
|
|
|
|
{ |
31
|
104
|
|
|
104
|
|
258
|
my(undef, $index) = @_; |
32
|
104
|
|
|
|
|
216
|
my $caller = caller; |
33
|
104
|
|
|
|
|
619
|
my($name) = map { lc $_ } $caller =~ /::([a-z]+Type)$/i; |
|
104
|
|
|
|
|
356
|
|
34
|
104
|
|
|
|
|
556
|
$cast[$index] = $ffi->function( "wasm_externtype_as_$name" => ['opaque'] => "wasm_${name}_t" )->sub_ref; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$ffi->custom_type('wasm_externtype_t' => { |
38
|
|
|
|
|
|
|
native_type => 'opaque', |
39
|
|
|
|
|
|
|
native_to_perl => sub { |
40
|
|
|
|
|
|
|
my $externtype = shift; |
41
|
|
|
|
|
|
|
Carp::croak("externtype error") unless defined $externtype; |
42
|
|
|
|
|
|
|
my $kind = _kind($externtype); |
43
|
|
|
|
|
|
|
$cast[$kind]->($externtype); |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
}); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub to_string |
49
|
|
|
|
|
|
|
{ |
50
|
0
|
|
|
0
|
1
|
|
die "internal error"; # pure virtual ish |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |