| 1 | # Copyright 2011-2012 Yuki Izumi. ( anneli AT cpan DOT org ) | ||||||||||||
| 2 | # This is free software; you can redistribute it and/or modify it under the | ||||||||||||
| 3 | # same terms as Perl itself. | ||||||||||||
| 4 | |||||||||||||
| 5 | package Erlang::Parser::Node::DefList; | ||||||||||||
| 6 | |||||||||||||
| 7 | 4 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 4 | with 'Erlang::Parser::Node'; | |||||||||||
| 9 | |||||||||||||
| 10 | 1378 | ▶ | has 'defs' => (is => 'rw', default => sub {[]}, isa => 'ArrayRef[Erlang::Parser::Node::Def]'); | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | sub _append { | ||||||||||||
| 13 | 3238 | ▶ | my ($self, $expr) = @_; | ||||||||||
|
Subroutine
_append: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | 3238 | push @{$self->defs}, $expr; | |||||||||||
| 15 | 3238 | $self; | |||||||||||
| 16 | } | ||||||||||||
| 17 | |||||||||||||
| 18 | sub print { | ||||||||||||
| 19 | 1378 | ▶ | my ($self, $fh, $depth) = @_; | ||||||||||
|
Subroutine
print: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||
| 20 | 1378 | ▶ | $depth ||= 0; | ||||||||||
|
Condition50%1/2
$depth ||= 0
MC/DC0%0/1
$depth ||= 0
$depth
Truth table50%1/2
A
A= $depth
| |||||||||||||
| 21 | |||||||||||||
| 22 | 1378 | my $first = 1; | |||||||||||
| 23 | 1378 | foreach (@{$self->defs}) { | |||||||||||
| 24 | 3238 | ▶ | if ($first) { $first = 0 } else { print $fh ";\n", "\t" x $depth } | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | 3238 | $_->print($fh, $depth); | |||||||||||
| 26 | } | ||||||||||||
| 27 | 1378 | print $fh ".\n"; | |||||||||||
| 28 | } | ||||||||||||
| 29 | |||||||||||||
| 30 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 31 | |||||||||||||
| 32 | =head1 NAME | ||||||||||||
| 33 | |||||||||||||
| 34 | Erlang::Parser::Node::DefList - a list of definitions for one function | ||||||||||||
| 35 | |||||||||||||
| 36 | =head1 DESCRIPTION | ||||||||||||
| 37 | |||||||||||||
| 38 | A set of definitions (alternative matches) for one function. | ||||||||||||
| 39 | |||||||||||||
| 40 | =head2 Accessors | ||||||||||||
| 41 | |||||||||||||
| 42 | =over 4 | ||||||||||||
| 43 | |||||||||||||
| 44 | =item C<defs> | ||||||||||||
| 45 | |||||||||||||
| 46 | A list of L<Erlang::Parser::Node::Def>s. | ||||||||||||
| 47 | |||||||||||||
| 48 | =back | ||||||||||||
| 49 | |||||||||||||
| 50 | =head2 Methods | ||||||||||||
| 51 | |||||||||||||
| 52 | =over 4 | ||||||||||||
| 53 | |||||||||||||
| 54 | =item C<print> | ||||||||||||
| 55 | |||||||||||||
| 56 | Pretty-prints the node to its filehandle argument. | ||||||||||||
| 57 | |||||||||||||
| 58 | =back | ||||||||||||
| 59 | |||||||||||||
| 60 | =head1 EXAMPLE | ||||||||||||
| 61 | |||||||||||||
| 62 | fac(0) -> | ||||||||||||
| 63 | 1; | ||||||||||||
| 64 | fac(N) -> | ||||||||||||
| 65 | N * fac(N - 1) | ||||||||||||
| 66 | |||||||||||||
| 67 | =cut | ||||||||||||
| 68 | |||||||||||||
| 69 | 4 | 1; | |||||||||||
| 70 | |||||||||||||
| 71 | # vim: set sw=4 ts=4: | ||||||||||||