| 1 | package Wasm::Wasmtime::TableType; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 26 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 26 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 26 | ▶ | use 5.008004; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 26 | ▶ | use base qw( Wasm::Wasmtime::ExternType ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 26 | ▶ | use Wasm::Wasmtime::FFI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 26 | ▶ | use Wasm::Wasmtime::ValType; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 26 | ▶ | use Ref::Util qw( is_ref is_plain_arrayref ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 26 | ▶ | use constant is_tabletype => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 26 | ▶ | use constant kind => 'tabletype'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | # ABSTRACT: Wasmtime table type class | ||||||||||||||||||||||||||||||||||||||||||
| 14 | 26 | our $VERSION = '0.24'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 26 | $ffi_prefix = 'wasm_tabletype_'; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 26 | $ffi->load_custom_type('::PtrObject' => 'wasm_tabletype_t' => __PACKAGE__); | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | $ffi->attach( new => ['wasm_valtype_t','uint32[2]'] => 'wasm_tabletype_t' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.7
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | my $xsub = shift; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | if(defined $_[0] && !is_ref($_[0]) && $_[0] =~ /^[0-9]+$/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $_[0] and not is_ref($_[0]) and $_[0] =~ /^[0-9]+$/
defined $_[0] and not is_ref($_[0])
MC/DC0%0/3
defined $_[0] and not is_ref($_[0]) and $_[0] =~ /^[0-9]+$/
defined $_[0]
not is_ref($_[0])
$_[0] =~ /^[0-9]+$/
Truth table50%2/4
A and not(B) and C
A= defined $_[0]B= not is_ref($_[0])C= $_[0] =~ /^[0-9]+$/
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my($ptr, $owner) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | return bless { | |||||||||||||||||||||||||||||||||||||||||
| 28 | ptr => $ptr, | ||||||||||||||||||||||||||||||||||||||||||
| 29 | owner => $owner, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | else | ||||||||||||||||||||||||||||||||||||||||||
| 33 | { | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | my($valtype, $limit) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | if(ref($valtype) eq 'Wasm::Wasmtime::ValType') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | $valtype = Wasm::Wasmtime::ValType->new($valtype->kind); | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | else | ||||||||||||||||||||||||||||||||||||||||||
| 40 | { | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | $valtype = Wasm::Wasmtime::ValType->new($valtype); | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | Carp::croak("bad limits") unless is_plain_arrayref($limit); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | ▶ | Carp::croak("no minumum in limit") unless defined $limit->[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | ▶ | $limit->[1] = 0xffffffff unless defined $limit->[1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | my $self = $xsub->($valtype, $limit); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 3 | delete $valtype->{ptr}; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 26 | }); | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 7 | ▶ | $ffi->attach( element => ['wasm_tabletype_t'] => 'wasm_valtype_t' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 7 | my($xsub, $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 7 | my $valtype = $xsub->($self); | |||||||||||||||||||||||||||||||||||||||||
| 56 | 7 | $valtype->{owner} = $self; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 7 | $valtype; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 26 | }); | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 7 | ▶ | $ffi->attach( limits => ['wasm_tabletype_t'] => 'uint32[2]' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 7 | my($xsub, $self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 7 | $xsub->($self); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 26 | }); | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | sub to_string | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_string: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | my($min, $max) = @{ $self->limits }; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | my $string = "$min "; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | ▶ | $string .= "$max " if $max != 0xffffffff; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 3 | $string .= $self->element->to_string; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 26 | __PACKAGE__->_cast(2); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 26 | _generate_destroy(); | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 26 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | __END__ | ||||||||||||||||||||||||||||||||||||||||||