| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::plasm; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
938449
|
use strict; |
|
|
4
|
|
|
|
|
37
|
|
|
|
4
|
|
|
|
|
103
|
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
86
|
|
|
5
|
4
|
|
|
4
|
|
67
|
use 5.010; |
|
|
4
|
|
|
|
|
12
|
|
|
6
|
4
|
|
|
4
|
|
2108
|
use Pod::Usage qw( pod2usage ); |
|
|
4
|
|
|
|
|
138267
|
|
|
|
4
|
|
|
|
|
404
|
|
|
7
|
4
|
|
|
4
|
|
3202
|
use Getopt::Long qw( GetOptions ); |
|
|
4
|
|
|
|
|
36166
|
|
|
|
4
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Perl WebAssembly command line tool |
|
10
|
|
|
|
|
|
|
our $VERSION = '0.03'; # VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub main |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
14
|
|
|
14
|
0
|
134555
|
my $class = shift; # unused |
|
16
|
|
|
|
|
|
|
|
|
17
|
14
|
|
|
|
|
82
|
Getopt::Long::Configure('permute'); |
|
18
|
|
|
|
|
|
|
|
|
19
|
14
|
50
|
66
|
|
|
562
|
if(defined $_[0] && $_[0] =~ /\.wasm$/) |
|
20
|
|
|
|
|
|
|
{ |
|
21
|
0
|
|
|
|
|
0
|
unshift @_, 'run'; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
14
|
100
|
100
|
|
|
91
|
if(defined $_[0] && $_[0] !~ /^-/) |
|
25
|
|
|
|
|
|
|
{ |
|
26
|
9
|
|
|
|
|
18
|
my $cmd = shift; |
|
27
|
9
|
|
|
|
|
25
|
my $class = "App::plasm::$cmd"; |
|
28
|
9
|
|
|
|
|
83
|
my $main = $class->can('main'); |
|
29
|
9
|
100
|
|
|
|
37
|
pod2usage({ |
|
30
|
|
|
|
|
|
|
-message => "no subcommand '$cmd'", |
|
31
|
|
|
|
|
|
|
-exitval => 2, |
|
32
|
|
|
|
|
|
|
}) unless defined $main; |
|
33
|
8
|
|
|
|
|
29
|
return $main->(@_); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
else |
|
36
|
|
|
|
|
|
|
{ |
|
37
|
5
|
|
|
|
|
19
|
local @ARGV = @_; |
|
38
|
|
|
|
|
|
|
GetOptions( |
|
39
|
1
|
|
|
1
|
|
356
|
'help|h' => sub { pod2usage({ -exitval => 0 }) }, |
|
40
|
1
|
|
50
|
1
|
|
414
|
'version|v' => sub { print "plasm version @{[ App::plasm->VERSION || 'dev' ]} Wasm.pm @{[ Wasm->VERSION ]}\n"; exit 0 }, |
|
|
1
|
|
|
|
|
18
|
|
|
|
1
|
|
|
|
|
25
|
|
|
|
1
|
|
|
|
|
7
|
|
|
41
|
5
|
100
|
|
|
|
51
|
) or pod2usage({ -exitval => 2 }); |
|
42
|
2
|
|
|
|
|
319
|
pod2usage({ -exitval => 2 }); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
package App::plasm::run; |
|
47
|
|
|
|
|
|
|
|
|
48
|
4
|
|
|
4
|
|
1836
|
use Pod::Usage qw( pod2usage ); |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
166
|
|
|
49
|
4
|
|
|
4
|
|
19
|
use Getopt::Long qw( GetOptions ); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
12
|
|
|
50
|
4
|
|
|
4
|
|
2409
|
use Wasm 0.08; |
|
|
4
|
|
|
|
|
551570
|
|
|
|
4
|
|
|
|
|
24
|
|
|
51
|
4
|
|
|
4
|
|
1927
|
use Wasm::Hook; |
|
|
4
|
|
|
|
|
78282
|
|
|
|
4
|
|
|
|
|
22
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $sandbox; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub main |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
5
|
|
|
5
|
|
16
|
local @ARGV = @_; |
|
58
|
|
|
|
|
|
|
|
|
59
|
5
|
|
|
|
|
13
|
Getopt::Long::Configure('require_order'); |
|
60
|
|
|
|
|
|
|
|
|
61
|
5
|
|
|
|
|
105
|
my @pod = (-verbose => 99, -sections => "SUBCOMMANDS/run"); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
GetOptions( |
|
64
|
1
|
|
|
1
|
|
269
|
'help|h' => sub { pod2usage({ -exitval => 0, @pod }) }, |
|
65
|
5
|
100
|
|
|
|
61
|
) or pod2usage({ -exitval => 2, @pod }); |
|
66
|
|
|
|
|
|
|
|
|
67
|
3
|
|
|
|
|
505
|
my $filename = shift @ARGV; |
|
68
|
|
|
|
|
|
|
|
|
69
|
3
|
50
|
|
|
|
10
|
pod2usage({ @pod, |
|
70
|
|
|
|
|
|
|
-exitval => 2, |
|
71
|
|
|
|
|
|
|
}) unless defined $filename; |
|
72
|
|
|
|
|
|
|
|
|
73
|
3
|
100
|
|
|
|
76
|
pod2usage({ @pod, |
|
74
|
|
|
|
|
|
|
-message => "File not found: $filename", |
|
75
|
|
|
|
|
|
|
-exitval => 2, |
|
76
|
|
|
|
|
|
|
}) unless -f $filename; |
|
77
|
|
|
|
|
|
|
|
|
78
|
2
|
|
|
|
|
7
|
my $class = "App::plasm::run::sandbox@{[ $sandbox++ ]}"; |
|
|
2
|
|
|
|
|
12
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
2
|
|
|
|
|
21
|
local $0 = $filename; |
|
81
|
|
|
|
|
|
|
|
|
82
|
2
|
|
|
|
|
32
|
Wasm->import( |
|
83
|
|
|
|
|
|
|
-api => 0, |
|
84
|
|
|
|
|
|
|
-package => $class, |
|
85
|
|
|
|
|
|
|
-file => $filename, |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
|
|
88
|
2
|
|
|
|
|
200091
|
my $start = $class->can('_start'); |
|
89
|
2
|
|
|
|
|
8
|
$start->(); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# TODO: detect exit value and pass that on... |
|
92
|
|
|
|
|
|
|
|
|
93
|
2
|
|
|
|
|
659
|
return 0; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
package App::plasm::dump; |
|
97
|
|
|
|
|
|
|
|
|
98
|
4
|
|
|
4
|
|
1104
|
use Pod::Usage qw( pod2usage ); |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
221
|
|
|
99
|
4
|
|
|
4
|
|
20
|
use Getopt::Long qw( GetOptions ); |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
26
|
|
|
100
|
4
|
|
|
4
|
|
2447
|
use Wasm::Wasmtime 0.08; |
|
|
4
|
|
|
|
|
205599
|
|
|
|
4
|
|
|
|
|
778
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub main |
|
103
|
|
|
|
|
|
|
{ |
|
104
|
2
|
|
|
2
|
|
8
|
local @ARGV = @_; |
|
105
|
|
|
|
|
|
|
|
|
106
|
2
|
|
|
|
|
8
|
my @pod = (-verbose => 99, -sections => "SUBCOMMANDS/run"); |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
GetOptions( |
|
109
|
0
|
|
|
0
|
|
0
|
'help|h' => sub { pod2usage({ -exitval => 0, @pod }) }, |
|
110
|
2
|
50
|
|
|
|
14
|
) or pod2usage({ -exitval => 2, @pod }); |
|
111
|
|
|
|
|
|
|
|
|
112
|
2
|
|
|
|
|
412
|
my $filename = shift @ARGV; |
|
113
|
|
|
|
|
|
|
|
|
114
|
2
|
50
|
|
|
|
8
|
pod2usage({ @pod, |
|
115
|
|
|
|
|
|
|
-exitval => 2, |
|
116
|
|
|
|
|
|
|
}) unless defined $filename; |
|
117
|
|
|
|
|
|
|
|
|
118
|
2
|
50
|
|
|
|
44
|
pod2usage({ @pod, |
|
119
|
|
|
|
|
|
|
-message => "File not found: $filename", |
|
120
|
|
|
|
|
|
|
-exitval => 2, |
|
121
|
|
|
|
|
|
|
}) unless -f $filename; |
|
122
|
|
|
|
|
|
|
|
|
123
|
2
|
|
|
|
|
33
|
my $module = Wasm::Wasmtime::Module->new( |
|
124
|
|
|
|
|
|
|
file => $filename, |
|
125
|
|
|
|
|
|
|
); |
|
126
|
|
|
|
|
|
|
|
|
127
|
2
|
|
|
|
|
4187
|
print $module->to_string; |
|
128
|
|
|
|
|
|
|
|
|
129
|
2
|
|
|
|
|
2113
|
return 0; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
package App::plasm::wat; |
|
133
|
|
|
|
|
|
|
|
|
134
|
4
|
|
|
4
|
|
38
|
use Pod::Usage qw( pod2usage ); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
225
|
|
|
135
|
4
|
|
|
4
|
|
21
|
use Getopt::Long qw( GetOptions ); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
43
|
|
|
136
|
4
|
|
|
4
|
|
2212
|
use Wasm::Wasmtime::Wat2Wasm qw( wat2wasm ); |
|
|
4
|
|
|
|
|
2576
|
|
|
|
4
|
|
|
|
|
193
|
|
|
137
|
4
|
|
|
4
|
|
25
|
use Path::Tiny qw( path ); |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
1019
|
|
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub main |
|
140
|
|
|
|
|
|
|
{ |
|
141
|
1
|
|
|
1
|
|
2
|
local @ARGV = @_; |
|
142
|
|
|
|
|
|
|
|
|
143
|
1
|
|
|
|
|
3
|
my @pod = (-verbose => 99, -sections => "SUBCOMMANDS/wat"); |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
GetOptions( |
|
146
|
0
|
|
|
0
|
|
0
|
'help|h' => sub { pod2usage({ -exitval => 0, @pod }) }, |
|
147
|
1
|
50
|
|
|
|
6
|
) or pod2usage({ -exitval => 2, @pod }); |
|
148
|
|
|
|
|
|
|
|
|
149
|
1
|
|
|
|
|
328
|
my $filename = shift @ARGV; |
|
150
|
|
|
|
|
|
|
|
|
151
|
1
|
50
|
|
|
|
3
|
pod2usage({ @pod, |
|
152
|
|
|
|
|
|
|
-exitval => 2, |
|
153
|
|
|
|
|
|
|
}) unless defined $filename; |
|
154
|
|
|
|
|
|
|
|
|
155
|
1
|
50
|
|
|
|
19
|
pod2usage({ @pod, |
|
156
|
|
|
|
|
|
|
-message => "File not found: $filename", |
|
157
|
|
|
|
|
|
|
-exitval => 2, |
|
158
|
|
|
|
|
|
|
}) unless -f $filename; |
|
159
|
|
|
|
|
|
|
|
|
160
|
1
|
|
|
|
|
27
|
my $in = path($filename); |
|
161
|
1
|
|
|
|
|
44
|
my $out = $in->parent->child(do { |
|
162
|
1
|
|
|
|
|
89
|
my $basename = $in->basename; |
|
163
|
1
|
|
|
|
|
14
|
$basename =~ s/\.wat$//; |
|
164
|
1
|
|
|
|
|
5
|
$basename . '.wasm'; |
|
165
|
|
|
|
|
|
|
}); |
|
166
|
|
|
|
|
|
|
|
|
167
|
1
|
50
|
|
|
|
34
|
pod2usage({ @pod, |
|
168
|
|
|
|
|
|
|
-message => "Output file already exists: $out", |
|
169
|
|
|
|
|
|
|
-exitval => 2, |
|
170
|
|
|
|
|
|
|
}) if -e $out; |
|
171
|
|
|
|
|
|
|
|
|
172
|
1
|
|
|
|
|
18
|
$out->spew_raw(wat2wasm($in->slurp_utf8)); |
|
173
|
|
|
|
|
|
|
|
|
174
|
1
|
|
|
|
|
1940
|
return 0; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
__END__ |