line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::Extern; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
3361
|
use strict; |
|
16
|
|
|
|
|
33
|
|
|
16
|
|
|
|
|
480
|
|
4
|
16
|
|
|
16
|
|
88
|
use warnings; |
|
16
|
|
|
|
|
26
|
|
|
16
|
|
|
|
|
395
|
|
5
|
16
|
|
|
16
|
|
248
|
use 5.008004; |
|
16
|
|
|
|
|
51
|
|
6
|
16
|
|
|
16
|
|
1716
|
use Wasm::Wasmtime::FFI; |
|
16
|
|
|
|
|
35
|
|
|
16
|
|
|
|
|
7586
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Wasm::Wasmtime::Func; |
9
|
|
|
|
|
|
|
require Wasm::Wasmtime::Global; |
10
|
|
|
|
|
|
|
require Wasm::Wasmtime::Table; |
11
|
|
|
|
|
|
|
require Wasm::Wasmtime::Memory; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Wasmtime extern class |
14
|
|
|
|
|
|
|
our $VERSION = '0.21'; # VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$ffi_prefix = 'wasm_extern_'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$ffi->attach( [ kind => '_kind' ] => ['opaque'] => 'uint8' ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my @cast; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub _cast |
24
|
|
|
|
|
|
|
{ |
25
|
64
|
|
|
64
|
|
157
|
my(undef, $index) = @_; |
26
|
64
|
|
|
|
|
137
|
my $caller = caller; |
27
|
64
|
|
|
|
|
361
|
my($name) = map { lc $_ } $caller =~ /::([a-z]+)$/i; |
|
64
|
|
|
|
|
233
|
|
28
|
64
|
|
|
|
|
362
|
$cast[$index] = $ffi->function( "wasm_extern_as_$name" => ['opaque'] => "wasm_${name}_t" )->sub_ref; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$ffi->custom_type('wasm_extern_t' => { |
32
|
|
|
|
|
|
|
native_type => 'opaque', |
33
|
|
|
|
|
|
|
native_to_perl => sub { |
34
|
|
|
|
|
|
|
my $extern = shift; |
35
|
|
|
|
|
|
|
Carp::croak("extern error") unless defined $extern; |
36
|
|
|
|
|
|
|
my $kind = _kind($extern); |
37
|
|
|
|
|
|
|
$cast[$kind]->($extern); |
38
|
|
|
|
|
|
|
}, |
39
|
|
|
|
|
|
|
}); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$ffi->attach_cast('new', 'opaque', 'wasm_extern_t', sub { |
42
|
|
|
|
|
|
|
my($xsub, undef, $ptr, $owner) = @_; |
43
|
|
|
|
|
|
|
my $self = $xsub->($ptr); |
44
|
|
|
|
|
|
|
$self->{owner} = $owner; |
45
|
|
|
|
|
|
|
$self; |
46
|
|
|
|
|
|
|
}); |
47
|
|
|
|
|
|
|
|
48
|
16
|
|
|
16
|
|
235
|
use constant is_func => 0; |
|
16
|
|
|
|
|
65
|
|
|
16
|
|
|
|
|
1332
|
|
49
|
16
|
|
|
16
|
|
119
|
use constant is_global => 0; |
|
16
|
|
|
|
|
37
|
|
|
16
|
|
|
|
|
877
|
|
50
|
16
|
|
|
16
|
|
114
|
use constant is_table => 0; |
|
16
|
|
|
|
|
33
|
|
|
16
|
|
|
|
|
916
|
|
51
|
16
|
|
|
16
|
|
106
|
use constant is_memory => 0; |
|
16
|
|
|
|
|
37
|
|
|
16
|
|
|
|
|
1460
|
|
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
0
|
1
|
|
sub kind { die "internal error" }; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
_generate_vec_class(); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |