line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::GlobalType; |
2
|
|
|
|
|
|
|
|
3
|
26
|
|
|
26
|
|
222815
|
use strict; |
|
26
|
|
|
|
|
60
|
|
|
26
|
|
|
|
|
808
|
|
4
|
26
|
|
|
26
|
|
132
|
use warnings; |
|
26
|
|
|
|
|
74
|
|
|
26
|
|
|
|
|
589
|
|
5
|
26
|
|
|
26
|
|
464
|
use 5.008004; |
|
26
|
|
|
|
|
89
|
|
6
|
26
|
|
|
26
|
|
154
|
use base qw( Wasm::Wasmtime::ExternType ); |
|
26
|
|
|
|
|
59
|
|
|
26
|
|
|
|
|
3503
|
|
7
|
26
|
|
|
26
|
|
191
|
use Wasm::Wasmtime::FFI; |
|
26
|
|
|
|
|
58
|
|
|
26
|
|
|
|
|
2605
|
|
8
|
26
|
|
|
26
|
|
5942
|
use Wasm::Wasmtime::ValType; |
|
26
|
|
|
|
|
72
|
|
|
26
|
|
|
|
|
842
|
|
9
|
26
|
|
|
26
|
|
160
|
use Ref::Util qw( is_ref ); |
|
26
|
|
|
|
|
47
|
|
|
26
|
|
|
|
|
1197
|
|
10
|
26
|
|
|
26
|
|
164
|
use Carp (); |
|
26
|
|
|
|
|
56
|
|
|
26
|
|
|
|
|
566
|
|
11
|
26
|
|
|
26
|
|
138
|
use constant is_globaltype => 1; |
|
26
|
|
|
|
|
57
|
|
|
26
|
|
|
|
|
1655
|
|
12
|
26
|
|
|
26
|
|
175
|
use constant kind => 'globaltype'; |
|
26
|
|
|
|
|
53
|
|
|
26
|
|
|
|
|
13923
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: Wasmtime global type class |
15
|
|
|
|
|
|
|
our $VERSION = '0.21'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$ffi_prefix = 'wasm_globaltype_'; |
19
|
|
|
|
|
|
|
$ffi->load_custom_type('::PtrObject' => 'wasm_globaltype_t' => __PACKAGE__); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my %mutability = ( |
23
|
|
|
|
|
|
|
const => 0, |
24
|
|
|
|
|
|
|
var => 1, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$ffi->attach( new => ['wasm_valtype_t','uint8'] => 'wasm_globaltype_t' => sub { |
28
|
|
|
|
|
|
|
my $xsub = shift; |
29
|
|
|
|
|
|
|
my $class = shift; |
30
|
|
|
|
|
|
|
my $ptr; |
31
|
|
|
|
|
|
|
my $owner; |
32
|
|
|
|
|
|
|
if(defined $_[0] && !is_ref($_[0]) && $_[0] =~ /^[0-9]+$/) |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
my($ptr, $owner) = @_; |
35
|
|
|
|
|
|
|
return bless { |
36
|
|
|
|
|
|
|
ptr => $ptr, |
37
|
|
|
|
|
|
|
owner => $owner, |
38
|
|
|
|
|
|
|
}, $class; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else |
41
|
|
|
|
|
|
|
{ |
42
|
|
|
|
|
|
|
my($valtype, $mutability) = @_; |
43
|
|
|
|
|
|
|
if(ref($valtype) eq 'Wasm::Wasmtime::ValType') |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
$valtype = Wasm::Wasmtime::ValType->new($valtype->kind); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
else |
48
|
|
|
|
|
|
|
{ |
49
|
|
|
|
|
|
|
$valtype = Wasm::Wasmtime::ValType->new($valtype); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
Carp::croak("mutability must be one of 'const' or 'var'") unless defined $mutability{$mutability}; |
52
|
|
|
|
|
|
|
my $self = $xsub->($valtype, $mutability{$mutability}); |
53
|
|
|
|
|
|
|
delete $valtype->{ptr}; |
54
|
|
|
|
|
|
|
return $self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
}); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$ffi->attach( content => ['wasm_globaltype_t'] => 'wasm_valtype_t' => sub { |
60
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
61
|
|
|
|
|
|
|
my $valtype = $xsub->($self); |
62
|
|
|
|
|
|
|
$valtype->{owner} = $self; |
63
|
|
|
|
|
|
|
$valtype; |
64
|
|
|
|
|
|
|
}); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my @mutability = ( |
68
|
|
|
|
|
|
|
'const', |
69
|
|
|
|
|
|
|
'var', |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$ffi->attach( mutability => ['wasm_globaltype_t'] => 'uint8' => sub { |
73
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
74
|
|
|
|
|
|
|
$mutability[$xsub->($self)]; |
75
|
|
|
|
|
|
|
}); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub to_string |
79
|
|
|
|
|
|
|
{ |
80
|
3
|
|
|
3
|
1
|
620
|
my($self) = @_; |
81
|
3
|
|
|
|
|
10
|
return sprintf("(%s %s)", $self->mutability, $self->content->to_string); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__PACKAGE__->_cast(1); |
85
|
|
|
|
|
|
|
_generate_destroy(); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |