PJVM/Runtime/Class.pm

filter: Statementstmt 30.1% 16 / 53 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 45.4% 5 / 11 Podpod 0.0% 0 / 5 totaltotal 28.7% 21 / 73 CC 5 SCAR 19.5
CC
5
Cov
28%
new_from_spec
20.0
get_method
6.0
__ANON__
2.0
CRAP 7.0
↑ Summary PJVM/Bytecode/Reader.pm »
1 package PJVM::Runtime::Class;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use PJVM::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use PJVM::Access qw(:flags);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use Object::Tiny qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
10 qname
11 methods
12 methods_access
13 fields
14 fields_access
15 ee
16 4 );
17  
18 0 ▶sub new_from_spec {
Subroutine new_from_spec: not called CC=4 SCAR=30.0
Pod undocumented
19 0 my ($pkg, $runtime, $spec) = @_;
20
21 # Methods
22 0 my $ee = $runtime->default_execution_engine;
23 0 my (%methods, %methods_access);
24 0 for my $method (@{$spec->methods}) {
25 0 my $mkey = $method->name . "#" . $method->signature;
26
27 # Let the engine have a chance to compile this if we want too
28 0 my $cb = $ee->compile($method->code);
29 0 ▶ $methods{$mkey} = ref $cb eq "CODE" ? $cb : sub { $ee->execute($cb) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
ref $cb eq 'CODE' ? : 0 0 0
30 0 $methods_access{$mkey} = $method->access_flags;
31 }
32
33 # Fields
34 0 my (%fields, %fields_access);
35 0 for my $field (@{$spec->fields}) {
36 0 $fields{$field->name} = $field->signature;
37 0 $fields_access{$field->name} = $field->access_flags;
38 }
39
40 0 my $self = $pkg->SUPER::new(
41 qname => $spec->name,
42 methods => \%methods,
43 methods_acces => \%methods_access,
44 fields => \%fields,
45 fields_access => \%fields_access,
46 access_flags => $spec->access_flags,
47 );
48
49 0 return $self;
50 }
51  
52 0 ▶sub class {
Subroutine class: not called CC=1 SCAR=6.9
Pod undocumented
53 0 my $self = shift;
54 0 return $self;
55 }
56  
57 0 ▶sub get_method {
Subroutine get_method: not called CC=2 SCAR=17.9
Pod undocumented
58 0 my ($self, $signature) = @_;
59 0 my $method = $self->{methods}->{$signature};
60 0 ▶ die "AbstractMethodError" unless $method;
Branch: 1 branch
BranchTrueFalseTotal
unless $method 0 0 0
61 0 return $method;
62 }
63 0 ▶sub static_fields {
Subroutine static_fields: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my $self = shift;
65 0 my $fields = $self->fields;
66 0 my $fields_access = $self->fields_access;
67 0 my %static = map { $_ => $fields->{$_} } grep { $fields_access->{$_} & ACC_STATIC } keys %$fields;
68 0 return \%static;
69 }
70  
71 0 ▶sub instance_fields {
Subroutine instance_fields: not called CC=1 SCAR=6.9
Pod undocumented
72 0 my $self = shift;
73 0 my $fields = $self->fields;
74 0 my $fields_access = $self->fields_access;
75 0 my %static = map { $_ => $fields->{$_} } grep { !($fields_access->{$_} & ACC_STATIC) } keys %$fields;
76 0 return \%static;
77 }
78  
79 4 1;
80 __END__
↑ Summary PJVM/Bytecode/Reader.pm »