ClassFile/Util/AccessFlagsStringification.pm

filter: Statementstmt 68.0% 17 / 25 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 58.3% 21 / 36 SCAR 12.9
CC
3
Cov
59%
accessFlagsStringificator
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.6
« ClassFile/Util/ArrayStringification.pm ↑ Summary ClassFile/Util/MarpaTrace.pm »
1 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 6 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package MarpaX::Java::ClassFile::Util::AccessFlagsStringification;
5 6 ▶use Exporter 'import'; # gives you Exporter's import() method directly
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use Scalar::Util qw/blessed/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 our @EXPORT_OK = qw/accessFlagsStringificator/;
8  
9 # ABSTRACT: Returns the string describing access flags
10  
11 6 our $VERSION = '0.008'; # VERSION
12  
13 6 our $AUTHORITY = 'cpan:JDDPAUSE'; # AUTHORITY
14  
15 6 my %_ACCESS_FLAG = (
16 'ClassFile' =>
17 [
18 [ ACC_PUBLIC => 0x0001 ],
19 [ ACC_FINAL => 0x0010 ],
20 [ ACC_SUPER => 0x0020 ],
21 [ ACC_INTERFACE => 0x0200 ],
22 [ ACC_ABSTRACT => 0x0400 ],
23 [ ACC_SYNTHETIC => 0x1000 ],
24 [ ACC_ANNOTATION => 0x2000 ],
25 [ ACC_ENUM => 0x4000 ]
26 ],
27 'FieldInfo' =>
28 [
29 [ ACC_PUBLIC => 0x0001 ],
30 [ ACC_PRIVATE => 0x0002 ],
31 [ ACC_PROTECTED => 0x0004 ],
32 [ ACC_STATIC => 0x0008 ],
33 [ ACC_FINAL => 0x0010 ],
34 [ ACC_VOLATILE => 0x0040 ],
35 [ ACC_TRANSIENT => 0x0080 ],
36 [ ACC_SYNTHETIC => 0x1000 ],
37 [ ACC_ENUM => 0x4000 ]
38 ],
39 'MethodInfo' =>
40 [
41 [ ACC_PUBLIC => 0x0001 ],
42 [ ACC_PRIVATE => 0x0002 ],
43 [ ACC_PROTECTED => 0x0004 ],
44 [ ACC_STATIC => 0x0008 ],
45 [ ACC_FINAL => 0x0010 ],
46 [ ACC_SYNCHRONIZED => 0x0020 ],
47 [ ACC_BRIDGE => 0x0040 ],
48 [ ACC_VARARGS => 0x0080 ],
49 [ ACC_NATIVE => 0x0100 ],
50 [ ACC_ABSTRACT => 0x0400 ],
51 [ ACC_STRICT => 0x0800 ],
52 [ ACC_SYNTHETIC => 0x1000 ]
53 ],
54 'Parameter' =>
55 [
56 [ ACC_FINAL => 0x0010 ],
57 [ ACC_SYNTHETIC => 0x1000 ],
58 [ ACC_MANDATED => 0x8000 ]
59 ],
60 'Class' =>
61 [
62 [ ACC_PUBLIC => 0x0001 ],
63 [ ACC_PRIVATE => 0x0002 ],
64 [ ACC_PROTECTED => 0x0004 ],
65 [ ACC_STATIC => 0x0008 ],
66 [ ACC_FINAL => 0x0010 ],
67 [ ACC_INTERFACE => 0x0200 ],
68 [ ACC_ABSTRACT => 0x0400 ],
69 [ ACC_SYNTHETIC => 0x1000 ],
70 [ ACC_ANNOTATION => 0x2000 ],
71 [ ACC_ENUM => 0x4000 ]
72 ]
73 );
74  
75  
76 sub accessFlagsStringificator {
77 # my ($self, $access_flags) = @_;
78  
79 0 ▶ my $blessed = blessed($_[0]) // '';
Subroutine accessFlagsStringificator: not called CC=3 SCAR=24.8
Pod undocumented
Condition0%0/2
builtin::blessed($_[0]) // ""
l!l
00
MC/DC0%0/1
builtin::blessed($_[0]) // ""
builtin::blessed($_[0])
Truth table0%0/2
A
A= builtin::blessed($_[0])
Aresult
11
00
80 0 $blessed =~ s/^.*:://;
81  
82 0 ▶ return '' unless exists($_ACCESS_FLAG{$blessed});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $_ACCESS_FLAG{$blessed} 0 0 0
83  
84 0 my $hash = $_ACCESS_FLAG{$blessed};
85 0 join(', ', map { $hash->[$_]->[0] } grep { ($_[1] & $hash->[$_]->[1]) == $hash->[$_]->[1] } (0..$#{$hash}))
86 }
87  
88 6 1;
89  
90 __END__
91  
92 =pod
93  
94 =encoding UTF-8
95  
96 =head1 NAME
97  
98 MarpaX::Java::ClassFile::Util::AccessFlagsStringification - Returns the string describing access flags
99  
100 =head1 VERSION
101  
102 version 0.008
103  
104 =head1 AUTHOR
105  
106 Jean-Damien Durand <jeandamiendurand@free.fr>
107  
108 =head1 COPYRIGHT AND LICENSE
109  
110 This software is copyright (c) 2016 by Jean-Damien Durand.
111  
112 This is free software; you can redistribute it and/or modify it under
113 the same terms as the Perl 5 programming language system itself.
114  
115 =cut
« ClassFile/Util/ArrayStringification.pm ↑ Summary ClassFile/Util/MarpaTrace.pm »