line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::Trap; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
547
|
use strict; |
|
17
|
|
|
|
|
36
|
|
|
17
|
|
|
|
|
522
|
|
4
|
17
|
|
|
17
|
|
86
|
use warnings; |
|
17
|
|
|
|
|
32
|
|
|
17
|
|
|
|
|
381
|
|
5
|
17
|
|
|
17
|
|
272
|
use 5.008004; |
|
17
|
|
|
|
|
57
|
|
6
|
17
|
|
|
17
|
|
1912
|
use Wasm::Wasmtime::FFI; |
|
17
|
|
|
|
|
61
|
|
|
17
|
|
|
|
|
2047
|
|
7
|
17
|
|
|
17
|
|
4375
|
use Wasm::Wasmtime::Store; |
|
17
|
|
|
|
|
53
|
|
|
17
|
|
|
|
|
1333
|
|
8
|
|
|
|
|
|
|
use overload |
9
|
4
|
|
|
4
|
|
1478
|
'""' => sub { shift->message . "\n" }, |
10
|
12
|
|
|
12
|
|
64
|
bool => sub { 1 }, |
11
|
17
|
|
|
17
|
|
142
|
fallback => 1; |
|
17
|
|
|
|
|
43
|
|
|
17
|
|
|
|
|
255
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Wasmtime trap class |
14
|
|
|
|
|
|
|
our $VERSION = '0.21'; # VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$ffi_prefix = 'wasm_trap_'; |
18
|
|
|
|
|
|
|
$ffi->load_custom_type('::PtrObject' => 'wasm_trap_t' => __PACKAGE__); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$ffi->attach( new => [ 'wasm_store_t', 'wasm_byte_vec_t*' ] => 'wasm_trap_t' => sub { |
22
|
|
|
|
|
|
|
my $xsub = shift; |
23
|
|
|
|
|
|
|
my $class = shift; |
24
|
|
|
|
|
|
|
if(@_ == 1) |
25
|
|
|
|
|
|
|
{ |
26
|
|
|
|
|
|
|
my $ptr = shift; |
27
|
|
|
|
|
|
|
return bless { |
28
|
|
|
|
|
|
|
ptr => $ptr, |
29
|
|
|
|
|
|
|
}, $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
my $store = shift; |
34
|
|
|
|
|
|
|
my $message = Wasm::Wasmtime::ByteVec->new($_[0]); |
35
|
|
|
|
|
|
|
return $xsub->($store, $message); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
}); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$ffi->attach( message => ['wasm_trap_t', 'wasm_byte_vec_t*'] => sub { |
41
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
42
|
|
|
|
|
|
|
my $message = Wasm::Wasmtime::ByteVec->new; |
43
|
|
|
|
|
|
|
$xsub->($self, $message); |
44
|
|
|
|
|
|
|
my $ret = $message->get; |
45
|
|
|
|
|
|
|
$ret =~ s/\0$//; |
46
|
|
|
|
|
|
|
$message->delete; |
47
|
|
|
|
|
|
|
$ret; |
48
|
|
|
|
|
|
|
}); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$ffi->attach( [ wasmtime_trap_exit_status => 'exit_status' ] => ['wasm_trap_t', 'int*'] => 'bool' => sub { |
52
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
53
|
|
|
|
|
|
|
my $status; |
54
|
|
|
|
|
|
|
$xsub->($self, \$status) |
55
|
|
|
|
|
|
|
? $status |
56
|
|
|
|
|
|
|
: undef; |
57
|
|
|
|
|
|
|
}); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
_generate_destroy(); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |