line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wasm::Wasmtime::Wat2Wasm; |
2
|
|
|
|
|
|
|
|
3
|
22
|
|
|
22
|
|
219913
|
use strict; |
|
22
|
|
|
|
|
55
|
|
|
22
|
|
|
|
|
692
|
|
4
|
22
|
|
|
22
|
|
121
|
use warnings; |
|
22
|
|
|
|
|
39
|
|
|
22
|
|
|
|
|
536
|
|
5
|
22
|
|
|
22
|
|
384
|
use 5.008004; |
|
22
|
|
|
|
|
81
|
|
6
|
22
|
|
|
22
|
|
589
|
use Wasm::Wasmtime::FFI; |
|
22
|
|
|
|
|
48
|
|
|
22
|
|
|
|
|
2652
|
|
7
|
22
|
|
|
22
|
|
157
|
use base qw( Exporter ); |
|
22
|
|
|
|
|
43
|
|
|
22
|
|
|
|
|
6795
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Convert WebAssembly Text to Wasm |
10
|
|
|
|
|
|
|
our $VERSION = '0.21'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw( wat2wasm ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$ffi_prefix = 'wasmtime_'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$ffi->attach( wat2wasm => ['wasm_byte_vec_t*','wasm_byte_vec_t*'] => 'wasmtime_error_t' => sub { |
19
|
|
|
|
|
|
|
my $xsub = shift; |
20
|
|
|
|
|
|
|
my $wat = Wasm::Wasmtime::ByteVec->new($_[0]); |
21
|
|
|
|
|
|
|
my $ret = Wasm::Wasmtime::ByteVec->new; |
22
|
|
|
|
|
|
|
my $error = $xsub->($wat, $ret); |
23
|
|
|
|
|
|
|
if($error) |
24
|
|
|
|
|
|
|
{ |
25
|
|
|
|
|
|
|
Carp::croak($error->message . "\nwat2wasm error"); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
my $wasm = $ret->get; |
30
|
|
|
|
|
|
|
$ret->delete; |
31
|
|
|
|
|
|
|
return $wasm; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
}); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |