line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::plasm; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
783526
|
use strict; |
|
3
|
|
|
|
|
31
|
|
|
3
|
|
|
|
|
89
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
70
|
|
5
|
3
|
|
|
3
|
|
62
|
use 5.008001; |
|
3
|
|
|
|
|
11
|
|
6
|
3
|
|
|
3
|
|
1704
|
use Pod::Usage qw( pod2usage ); |
|
3
|
|
|
|
|
117446
|
|
|
3
|
|
|
|
|
316
|
|
7
|
3
|
|
|
3
|
|
2518
|
use Getopt::Long qw( GetOptions ); |
|
3
|
|
|
|
|
31701
|
|
|
3
|
|
|
|
|
17
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Perl WebAssembly command line tool |
10
|
|
|
|
|
|
|
our $VERSION = '0.01'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub main |
14
|
|
|
|
|
|
|
{ |
15
|
13
|
|
|
13
|
0
|
138340
|
my $class = shift; # unused |
16
|
|
|
|
|
|
|
|
17
|
13
|
|
|
|
|
136
|
Getopt::Long::Configure('permute'); |
18
|
|
|
|
|
|
|
|
19
|
13
|
100
|
100
|
|
|
584
|
if(defined $_[0] && $_[0] !~ /^-/) |
20
|
|
|
|
|
|
|
{ |
21
|
8
|
|
|
|
|
23
|
my $cmd = shift; |
22
|
8
|
|
|
|
|
24
|
my $class = "App::plasm::$cmd"; |
23
|
8
|
|
|
|
|
77
|
my $main = $class->can('main'); |
24
|
8
|
100
|
|
|
|
35
|
pod2usage({ |
25
|
|
|
|
|
|
|
-message => "no subcommand '$cmd'", |
26
|
|
|
|
|
|
|
-exitval => 2, |
27
|
|
|
|
|
|
|
}) unless defined $main; |
28
|
7
|
|
|
|
|
26
|
return $main->(@_); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else |
31
|
|
|
|
|
|
|
{ |
32
|
5
|
|
|
|
|
17
|
local @ARGV = @_; |
33
|
|
|
|
|
|
|
GetOptions( |
34
|
1
|
|
|
1
|
|
276
|
'help|h' => sub { pod2usage({ -exitval => 0 }) }, |
35
|
1
|
|
50
|
1
|
|
477
|
'version|v' => sub { print "plasm version @{[ App::plasm->VERSION || 'dev' ]} Wasm.pm @{[ Wasm->VERSION ]}\n"; exit 0 }, |
|
1
|
|
|
|
|
20
|
|
|
1
|
|
|
|
|
66
|
|
|
1
|
|
|
|
|
13
|
|
36
|
5
|
100
|
|
|
|
43
|
) or pod2usage({ -exitval => 2 }); |
37
|
2
|
|
|
|
|
363
|
pod2usage({ -exitval => 2 }); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
package App::plasm::run; |
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
3
|
|
1370
|
use Pod::Usage qw( pod2usage ); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
141
|
|
44
|
3
|
|
|
3
|
|
20
|
use Getopt::Long qw( GetOptions ); |
|
3
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
16
|
|
45
|
3
|
|
|
3
|
|
1922
|
use Wasm 0.08; |
|
3
|
|
|
|
|
13199
|
|
|
3
|
|
|
|
|
20
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $sandbox; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub main |
50
|
|
|
|
|
|
|
{ |
51
|
5
|
|
|
5
|
|
17
|
local @ARGV = @_; |
52
|
|
|
|
|
|
|
|
53
|
5
|
|
|
|
|
25
|
Getopt::Long::Configure('require_order'); |
54
|
|
|
|
|
|
|
|
55
|
5
|
|
|
|
|
129
|
my @pod = (-verbose => 99, -sections => "SUBCOMMANDS/run"); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
GetOptions( |
58
|
1
|
|
|
1
|
|
336
|
'help|h' => sub { pod2usage({ -exitval => 0, @pod }) }, |
59
|
5
|
100
|
|
|
|
34
|
) or pod2usage({ -exitval => 2, @pod }); |
60
|
|
|
|
|
|
|
|
61
|
3
|
|
|
|
|
579
|
my $filename = shift @ARGV; |
62
|
|
|
|
|
|
|
|
63
|
3
|
50
|
|
|
|
10
|
pod2usage({ @pod, |
64
|
|
|
|
|
|
|
-exitval => 2, |
65
|
|
|
|
|
|
|
}) unless defined $filename; |
66
|
|
|
|
|
|
|
|
67
|
3
|
100
|
|
|
|
82
|
pod2usage({ @pod, |
68
|
|
|
|
|
|
|
-message => "File not found: $filename", |
69
|
|
|
|
|
|
|
-exitval => 2, |
70
|
|
|
|
|
|
|
}) unless -f $filename; |
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
|
|
7
|
my $class = "App::plasm::run::sandbox@{[ $sandbox++ ]}"; |
|
2
|
|
|
|
|
14
|
|
73
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
25
|
local $0 = $filename; |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
25
|
Wasm->import( |
77
|
|
|
|
|
|
|
-api => 0, |
78
|
|
|
|
|
|
|
-package => $class, |
79
|
|
|
|
|
|
|
-file => $filename, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
2
|
|
|
|
|
265418
|
my $start = $class->can('_start'); |
83
|
2
|
|
|
|
|
9
|
$start->(); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# TODO: detect exit value and pass that on... |
86
|
|
|
|
|
|
|
|
87
|
2
|
|
|
|
|
729
|
return 0; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
package App::plasm::dump; |
91
|
|
|
|
|
|
|
|
92
|
3
|
|
|
3
|
|
818
|
use Pod::Usage qw( pod2usage ); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
168
|
|
93
|
3
|
|
|
3
|
|
23
|
use Getopt::Long qw( GetOptions ); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
17
|
|
94
|
3
|
|
|
3
|
|
1730
|
use Wasm::Wasmtime 0.08; |
|
3
|
|
|
|
|
673912
|
|
|
3
|
|
|
|
|
641
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub main |
97
|
|
|
|
|
|
|
{ |
98
|
2
|
|
|
2
|
|
6
|
local @ARGV = @_; |
99
|
|
|
|
|
|
|
|
100
|
2
|
|
|
|
|
9
|
my @pod = (-verbose => 99, -sections => "SUBCOMMANDS/run"); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
GetOptions( |
103
|
0
|
|
|
0
|
|
0
|
'help|h' => sub { pod2usage({ -exitval => 0, @pod }) }, |
104
|
2
|
50
|
|
|
|
12
|
) or pod2usage({ -exitval => 2, @pod }); |
105
|
|
|
|
|
|
|
|
106
|
2
|
|
|
|
|
421
|
my $filename = shift @ARGV; |
107
|
|
|
|
|
|
|
|
108
|
2
|
50
|
|
|
|
6
|
pod2usage({ @pod, |
109
|
|
|
|
|
|
|
-exitval => 2, |
110
|
|
|
|
|
|
|
}) unless defined $filename; |
111
|
|
|
|
|
|
|
|
112
|
2
|
50
|
|
|
|
40
|
pod2usage({ @pod, |
113
|
|
|
|
|
|
|
-message => "File not found: $filename", |
114
|
|
|
|
|
|
|
-exitval => 2, |
115
|
|
|
|
|
|
|
}) unless -f $filename; |
116
|
|
|
|
|
|
|
|
117
|
2
|
|
|
|
|
20
|
my $module = Wasm::Wasmtime::Module->new( |
118
|
|
|
|
|
|
|
file => $filename, |
119
|
|
|
|
|
|
|
); |
120
|
|
|
|
|
|
|
|
121
|
2
|
|
|
|
|
6901
|
print $module->to_string; |
122
|
|
|
|
|
|
|
|
123
|
2
|
|
|
|
|
3001
|
return 0; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__ |