line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::Global; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
233049
|
use strict; |
|
16
|
|
|
|
|
51
|
|
|
16
|
|
|
|
|
537
|
|
4
|
16
|
|
|
16
|
|
88
|
use warnings; |
|
16
|
|
|
|
|
36
|
|
|
16
|
|
|
|
|
391
|
|
5
|
16
|
|
|
16
|
|
291
|
use 5.008004; |
|
16
|
|
|
|
|
60
|
|
6
|
16
|
|
|
16
|
|
115
|
use base qw( Wasm::Wasmtime::Extern ); |
|
16
|
|
|
|
|
49
|
|
|
16
|
|
|
|
|
2221
|
|
7
|
16
|
|
|
16
|
|
126
|
use Ref::Util qw( is_ref ); |
|
16
|
|
|
|
|
30
|
|
|
16
|
|
|
|
|
855
|
|
8
|
16
|
|
|
16
|
|
106
|
use Wasm::Wasmtime::FFI; |
|
16
|
|
|
|
|
62
|
|
|
16
|
|
|
|
|
1732
|
|
9
|
16
|
|
|
16
|
|
117
|
use Wasm::Wasmtime::Store; |
|
16
|
|
|
|
|
44
|
|
|
16
|
|
|
|
|
445
|
|
10
|
16
|
|
|
16
|
|
510
|
use Wasm::Wasmtime::GlobalType; |
|
16
|
|
|
|
|
65
|
|
|
16
|
|
|
|
|
638
|
|
11
|
16
|
|
|
16
|
|
102
|
use constant is_global => 1; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
951
|
|
12
|
16
|
|
|
16
|
|
115
|
use constant kind => 'global'; |
|
16
|
|
|
|
|
64
|
|
|
16
|
|
|
|
|
9557
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: Wasmtime global class |
15
|
|
|
|
|
|
|
our $VERSION = '0.23'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$ffi_prefix = 'wasm_global_'; |
19
|
|
|
|
|
|
|
$ffi->load_custom_type('::PtrObject' => 'wasm_global_t' => __PACKAGE__); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$ffi->attach( new => ['wasm_store_t', 'wasm_globaltype_t', 'wasm_val_t'] => 'wasm_global_t' => sub { |
23
|
|
|
|
|
|
|
my $xsub = shift; |
24
|
|
|
|
|
|
|
my $class = shift; |
25
|
|
|
|
|
|
|
if(is_ref $_[0]) |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
my($store, $globaltype, $value) = @_; |
28
|
|
|
|
|
|
|
$value = Wasm::Wasmtime::Val->new({ |
29
|
|
|
|
|
|
|
kind => $globaltype->content->kind_num, |
30
|
|
|
|
|
|
|
of => { $globaltype->content->kind => $value }, |
31
|
|
|
|
|
|
|
}); |
32
|
|
|
|
|
|
|
my $self = $xsub->($store, $globaltype, $value); |
33
|
|
|
|
|
|
|
$self->{store} = $store; |
34
|
|
|
|
|
|
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else |
37
|
|
|
|
|
|
|
{ |
38
|
|
|
|
|
|
|
my($ptr, $owner) = @_; |
39
|
|
|
|
|
|
|
bless { |
40
|
|
|
|
|
|
|
ptr => $ptr, |
41
|
|
|
|
|
|
|
owner => $owner, |
42
|
|
|
|
|
|
|
}, $class; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
}); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$ffi->attach( type => ['wasm_global_t'] => 'wasm_globaltype_t' => sub { |
48
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
49
|
|
|
|
|
|
|
my $type = $xsub->($self); |
50
|
|
|
|
|
|
|
$type->{owner} = $self->{owner} || $self; |
51
|
|
|
|
|
|
|
$type; |
52
|
|
|
|
|
|
|
}); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$ffi->attach( get => ['wasm_global_t', 'wasm_val_t'] => sub { |
56
|
|
|
|
|
|
|
my($xsub, $self) = @_; |
57
|
|
|
|
|
|
|
my $value = Wasm::Wasmtime::Val->new; |
58
|
|
|
|
|
|
|
$xsub->($self, $value); |
59
|
|
|
|
|
|
|
$value->to_perl; |
60
|
|
|
|
|
|
|
}); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$ffi->attach( set => ['wasm_global_t','wasm_val_t'] => sub { |
64
|
|
|
|
|
|
|
my($xsub, $self, $value) = @_; |
65
|
|
|
|
|
|
|
$value = Wasm::Wasmtime::Val->new({ |
66
|
|
|
|
|
|
|
kind => $self->type->content->kind_num, |
67
|
|
|
|
|
|
|
of => { $self->type->content->kind => $value }, |
68
|
|
|
|
|
|
|
}); |
69
|
|
|
|
|
|
|
$xsub->($self, $value); |
70
|
|
|
|
|
|
|
}); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub tie |
74
|
|
|
|
|
|
|
{ |
75
|
4
|
|
|
4
|
1
|
1709
|
my $self = shift; |
76
|
4
|
|
|
|
|
6
|
my $ref; |
77
|
4
|
|
|
|
|
17
|
tie $ref, __PACKAGE__, $self; |
78
|
4
|
|
|
|
|
14
|
\$ref; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
4
|
|
|
4
|
|
12
|
sub TIESCALAR { $_[1] } |
82
|
|
|
|
|
|
|
*FETCH = \&get; |
83
|
|
|
|
|
|
|
*STORE = \&set; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__PACKAGE__->_cast(1); |
86
|
|
|
|
|
|
|
_generate_destroy(); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |