| 1 | package PJVM::Class::Attribute::Code; | ||||||||||
| 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 Object::Tiny qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | max_stack | ||||||||||
| 8 | max_locals | ||||||||||
| 9 | code | ||||||||||
| 10 | exceptions_table | ||||||||||
| 11 | 3 | ); | |||||||||
| 12 | |||||||||||
| 13 | 9 | ▶ | sub new_from_io { | ||||||||
|
Subroutine
new_from_io: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||
| 14 | 9 | my ($pkg, $io, $cp) = @_; | |||||||||
| 15 | |||||||||||
| 16 | 9 | my $buff; | |||||||||
| 17 | |||||||||||
| 18 | # Stack stuff | ||||||||||
| 19 | 9 | read $io, $buff, 4; | |||||||||
| 20 | 9 | my ($max_stack, $max_locals) = unpack("nn", $buff); | |||||||||
| 21 | |||||||||||
| 22 | # Number of operations | ||||||||||
| 23 | 9 | read $io, $buff, 4; | |||||||||
| 24 | 9 | my $op_count = unpack("N", $buff); | |||||||||
| 25 | |||||||||||
| 26 | # Load code | ||||||||||
| 27 | 9 | read $io, $buff, $op_count; | |||||||||
| 28 | 9 | my $code = $buff; | |||||||||
| 29 | |||||||||||
| 30 | # Exceptions stuff | ||||||||||
| 31 | 9 | read $io, $buff, 2; | |||||||||
| 32 | 9 | my $ex_table_count = unpack("n", $buff); | |||||||||
| 33 | 9 | my @exceptions_table; | |||||||||
| 34 | 9 | ▶ | while ($ex_table_count--) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | read $io, $buff, 8; | |||||||||
| 36 | 0 | my ($start_pc, $end_pc, $handler_pc, $catch_type) = unpack("nnnn", $buff); | |||||||||
| 37 | 0 | push @exceptions_table, [$start_pc, $end_pc, $handler_pc, $catch_type]; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | # Attributes | ||||||||||
| 41 | 9 | read $io, $buff, 2; | |||||||||
| 42 | 9 | my $attributes_count = unpack("n", $buff); | |||||||||
| 43 | |||||||||||
| 44 | # Read attributes | ||||||||||
| 45 | 9 | my @attributes; | |||||||||
| 46 | 9 | ▶ | if ($attributes_count) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 9 | ▶ | while ($attributes_count--) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 9 | push @attributes, PJVM::Class::Attribute->new_from_io($io, $cp); | |||||||||
| 49 | } | ||||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 9 | my $self = $pkg->new( | |||||||||
| 53 | max_stack => $max_stack, | ||||||||||
| 54 | max_locals => $max_locals, | ||||||||||
| 55 | code => $code, | ||||||||||
| 56 | exceptions_table => \@exceptions_table, | ||||||||||
| 57 | attributes => \@attributes, | ||||||||||
| 58 | ); | ||||||||||
| 59 | |||||||||||
| 60 | 9 | return $self; | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 3 | 1; | |||||||||
| 64 | __END__ | ||||||||||