| 1 | package PJVM::Class::Method; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use PJVM::Access qw(:flags); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use PJVM::Class::Attribute; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Object::Tiny qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | access_flags | ||||||||||||||||||||||||||||
| 13 | name_index | ||||||||||||||||||||||||||||
| 14 | descriptor_index | ||||||||||||||||||||||||||||
| 15 | attributes | ||||||||||||||||||||||||||||
| 16 | parent_class | ||||||||||||||||||||||||||||
| 17 | 3 | ); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 9 | ▶ | sub new_from_io { | ||||||||||||||||||||||||||
|
Subroutine
new_from_io: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 20 | 9 | my ($pkg, $io, $cp, $parent_class) = @_; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 9 | my $buff; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 9 | read $io, $buff, 8; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 9 | my ($access_flags, $name_index, $descriptor_index, $attributes_count) = unpack("nnnn", $buff); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # Read attributes | ||||||||||||||||||||||||||||
| 29 | 9 | my @attributes; | |||||||||||||||||||||||||||
| 30 | 9 | ▶ | if ($attributes_count) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 9 | ▶ | while ($attributes_count--) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 9 | push @attributes, PJVM::Class::Attribute->new_from_io($io, $cp); | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 9 | my $self = $pkg->new( | |||||||||||||||||||||||||||
| 37 | access_flags => $access_flags, | ||||||||||||||||||||||||||||
| 38 | name_index => $name_index, | ||||||||||||||||||||||||||||
| 39 | descriptor_index => $descriptor_index, | ||||||||||||||||||||||||||||
| 40 | attributes => \@attributes, | ||||||||||||||||||||||||||||
| 41 | parent_class => $parent_class, | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 9 | weaken $self->parent_class; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 9 | return $self; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 7 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 50 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 51 | 7 | my $name = $self->parent_class->constant_pool->get($self->name_index); | |||||||||||||||||||||||||||
| 52 | 7 | return $name->value; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 9 | ▶ | sub signature { | ||||||||||||||||||||||||||
|
Subroutine
signature: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 9 | my $self = shift; | |||||||||||||||||||||||||||
| 57 | 9 | my $signature = $self->parent_class->constant_pool->get($self->descriptor_index); | |||||||||||||||||||||||||||
| 58 | 9 | return $signature->value; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 1 | ▶ | sub code { | ||||||||||||||||||||||||||
|
Subroutine
code: called CC=5 SCAR=23.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | # Locate first attribute which is a code | ||||||||||||||||||||||||||||
| 65 | 1 | for my $attribute (@{$self->attributes}) { | |||||||||||||||||||||||||||
| 66 | 1 | ▶ | if ($attribute->isa("PJVM::Class::Attribute::Code")) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 1 | return $attribute; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ($self->access_flags & ACC_NATIVE || $self->access_flags & ACC_ABSTRACT) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->access_flags & 256 or $self->access_flags & 1024
MC/DC0%0/2
$self->access_flags & 256 or $self->access_flags & 1024
$self->access_flags & 256
$self->access_flags & 1024
Truth table0%0/3
A or B
A= $self->access_flags & 256B= $self->access_flags & 1024
| |||||||||||||||||||||||||||||
| 72 | 0 | return; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | die "Method has no 'Code' attribute.. that is very very bad" | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | ▶ | sub bytecode { | ||||||||||||||||||||||||||
|
Subroutine
bytecode: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 79 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | # Locate first attribute which is a code | ||||||||||||||||||||||||||||
| 82 | 1 | my $code = $self->code; | |||||||||||||||||||||||||||
| 83 | 1 | ▶ | return $code->code if $code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | return ''; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 3 | 1; | |||||||||||||||||||||||||||
| 89 | __END__ | ||||||||||||||||||||||||||||