| 1 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 1 | ▶ | use warnings FATAL => 'all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | package MarpaX::Java::ClassFile::BNF::CodeAttribute; | ||
| 5 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | # ABSTRACT: Parsing of a Code_attribute | ||
| 8 | |||
| 9 | our $VERSION = '0.008'; # VERSION | ||
| 10 | |||
| 11 | our $AUTHORITY = 'cpan:JDDPAUSE'; # AUTHORITY | ||
| 12 | |||
| 13 | 1 | ▶ | use Data::Section -setup; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 1 | ▶ | use MarpaX::Java::ClassFile::Util::BNF qw/:all/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | # | ||
| 16 | # require because we do not import ANYTHING from these module, just require they are loaded | ||
| 17 | # | ||
| 18 | require Marpa::R2; | ||
| 19 | require MarpaX::Java::ClassFile::Struct::CodeAttribute; | ||
| 20 | require MarpaX::Java::ClassFile::BNF::AttributesArray; | ||
| 21 | require MarpaX::Java::ClassFile::BNF::ExceptionTableArray; | ||
| 22 | require MarpaX::Java::ClassFile::BNF::OpCodeArray; | ||
| 23 | |||
| 24 | my $_data = ${ __PACKAGE__->section_data('bnf') }; | ||
| 25 | my $_grammar = Marpa::R2::Scanless::G->new( { source => \__PACKAGE__->bnf($_data) } ); | ||
| 26 | |||
| 27 | # -------------------------------------------------------- | ||
| 28 | # What role MarpaX::Java::ClassFile::Role::Parser requires | ||
| 29 | # -------------------------------------------------------- | ||
| 30 | 0 | ▶ | sub grammar { $_grammar } |
|
Subroutine
grammar: not called CC=1 SCAR=6.9
| |||
| 31 | sub callbacks { return { | ||
| 32 | 0 | ▶ | "'exhausted" => sub { $_[0]->exhausted }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 33 | 0 | ▶ | 'code_length$' => sub { $_[0]->inner('OpCodeArray', originPos => $_[0]->pos, size => -1, max => $_[0]->pos + $_[0]->literalU4('code_length')) }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 34 | 0 | ▶ | 'exception_table_length$' => sub { $_[0]->inner('ExceptionTableArray', size => $_[0]->literalU2('exception_table_length')) }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 35 | 0 | ▶ | 'attributes_count$' => sub { $_[0]->inner('AttributesArray', size => $_[0]->literalU2('attributes_count')) } |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 36 | } | ||
| 37 | 0 | ▶ | } |
|
Subroutine
callbacks: not called CC=1 SCAR=6.9
| |||
| 38 | |||
| 39 | # --------------- | ||
| 40 | # Grammar actions | ||
| 41 | # --------------- | ||
| 42 | sub _Code_attribute { | ||
| 43 | # my ($self, $attribute_name_index, $attribute_length, $max_stack, $max_locals, $code_length, $code, $exception_table_length, $exception_table, $attributes_count, $attributes) = @_; | ||
| 44 | |||
| 45 | 0 | ▶ | MarpaX::Java::ClassFile::Struct::CodeAttribute->new( |
|
Subroutine
_Code_attribute: not called CC=1 SCAR=6.9
| |||
| 46 | _constant_pool => $_[ 0]->constant_pool, | ||
| 47 | attribute_name_index => $_[ 1], | ||
| 48 | attribute_length => $_[ 2], | ||
| 49 | max_stack => $_[ 3], | ||
| 50 | max_locals => $_[ 4], | ||
| 51 | code_length => $_[ 5], | ||
| 52 | code => $_[ 6], | ||
| 53 | exception_table_length => $_[ 7], | ||
| 54 | exception_table => $_[ 8], | ||
| 55 | attributes_count => $_[ 9], | ||
| 56 | attributes => $_[10] | ||
| 57 | ) | ||
| 58 | } | ||
| 59 | |||
| 60 | with 'MarpaX::Java::ClassFile::Role::Parser'; | ||
| 61 | |||
| 62 | 1; | ||
| 63 | |||
| 64 | =pod | ||
| 65 | |||
| 66 | =encoding UTF-8 | ||
| 67 | |||
| 68 | =head1 NAME | ||
| 69 | |||
| 70 | MarpaX::Java::ClassFile::BNF::CodeAttribute - Parsing of a Code_attribute | ||
| 71 | |||
| 72 | =head1 VERSION | ||
| 73 | |||
| 74 | version 0.008 | ||
| 75 | |||
| 76 | =head1 AUTHOR | ||
| 77 | |||
| 78 | Jean-Damien Durand <jeandamiendurand@free.fr> | ||
| 79 | |||
| 80 | =head1 COPYRIGHT AND LICENSE | ||
| 81 | |||
| 82 | This software is copyright (c) 2016 by Jean-Damien Durand. | ||
| 83 | |||
| 84 | This is free software; you can redistribute it and/or modify it under | ||
| 85 | the same terms as the Perl 5 programming language system itself. | ||
| 86 | |||
| 87 | =cut | ||
| 88 | |||
| 89 | __DATA__ | ||
| 90 | __[ bnf ]__ | ||
| 91 | event 'code_length$' = completed code_length | ||
| 92 | event 'exception_table_length$' = completed exception_table_length | ||
| 93 | event 'attributes_count$' = completed attributes_count | ||
| 94 | |||
| 95 | Code_attribute ::= attribute_name_index attribute_length max_stack max_locals code_length code exception_table_length exception_table attributes_count attributes action => _Code_attribute | ||
| 96 | attribute_name_index ::= U2 action => u2 | ||
| 97 | attribute_length ::= U4 action => u4 | ||
| 98 | max_stack ::= U2 action => u2 | ||
| 99 | max_locals ::= U2 action => u2 | ||
| 100 | code_length ::= U4 action => u4 | ||
| 101 | code ::= MANAGED action => ::first | ||
| 102 | exception_table_length ::= U2 action => u2 | ||
| 103 | exception_table ::= MANAGED action => ::first | ||
| 104 | attributes_count ::= U2 action => u2 | ||
| 105 | attributes ::= MANAGED action => ::first | ||