| 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::FunRef; | ||||||||||||
| 6 | |||||||||||||
| 7 | 4 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 4 | with 'Erlang::Parser::Node'; | |||||||||||
| 9 | |||||||||||||
| 10 | 4 | has 'module' => (is => 'rw', required => 0, isa => 'Maybe[Erlang::Parser::Node]'); | |||||||||||
| 11 | 4 | has 'function' => (is => 'rw', required => 1, isa => 'Str'); | |||||||||||
| 12 | 4 | has 'arity' => (is => 'rw', required => 1, isa => 'Int'); | |||||||||||
| 13 | |||||||||||||
| 14 | sub print { | ||||||||||||
| 15 | 38 | ▶ | my ($self, $fh, $depth) = @_; | ||||||||||
|
Subroutine
print: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||
| 16 | 38 | ▶ | $depth ||= 0; | ||||||||||
|
Condition50%1/2
$depth ||= 0
MC/DC0%0/1
$depth ||= 0
$depth
Truth table50%1/2
A
A= $depth
| |||||||||||||
| 17 | |||||||||||||
| 18 | 38 | print $fh 'fun '; | |||||||||||
| 19 | |||||||||||||
| 20 | 38 | ▶ | if (defined $self->module) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 21 | 2 | $self->module->print($fh, $depth); | |||||||||||
| 22 | 2 | print $fh ':'; | |||||||||||
| 23 | } | ||||||||||||
| 24 | |||||||||||||
| 25 | 38 | print $fh $self->function, '/', $self->arity; | |||||||||||
| 26 | } | ||||||||||||
| 27 | |||||||||||||
| 28 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 29 | |||||||||||||
| 30 | =head1 NAME | ||||||||||||
| 31 | |||||||||||||
| 32 | Erlang::Parser::Node::FunRef - a reference to a function | ||||||||||||
| 33 | |||||||||||||
| 34 | =head1 DESCRIPTION | ||||||||||||
| 35 | |||||||||||||
| 36 | A reference to a function (as a first-class value), either local to this | ||||||||||||
| 37 | module, or external. | ||||||||||||
| 38 | |||||||||||||
| 39 | =head2 Accessors | ||||||||||||
| 40 | |||||||||||||
| 41 | =over 4 | ||||||||||||
| 42 | |||||||||||||
| 43 | =item C<module> | ||||||||||||
| 44 | |||||||||||||
| 45 | An optional L<Erlang::Parser::Node> which returns as an atom the name of the | ||||||||||||
| 46 | module to find the function in. | ||||||||||||
| 47 | |||||||||||||
| 48 | =item C<function> | ||||||||||||
| 49 | |||||||||||||
| 50 | The name of the function (a plain string). | ||||||||||||
| 51 | |||||||||||||
| 52 | =item C<arity> | ||||||||||||
| 53 | |||||||||||||
| 54 | The arity of the function (a number). | ||||||||||||
| 55 | |||||||||||||
| 56 | =back | ||||||||||||
| 57 | |||||||||||||
| 58 | =head2 Methods | ||||||||||||
| 59 | |||||||||||||
| 60 | =over 4 | ||||||||||||
| 61 | |||||||||||||
| 62 | =item C<print> | ||||||||||||
| 63 | |||||||||||||
| 64 | Pretty-prints the node to its filehandle argument. | ||||||||||||
| 65 | |||||||||||||
| 66 | =back | ||||||||||||
| 67 | |||||||||||||
| 68 | =head1 EXAMPLE | ||||||||||||
| 69 | |||||||||||||
| 70 | fun ?MODULE:code_change/0 | ||||||||||||
| 71 | |||||||||||||
| 72 | =cut | ||||||||||||
| 73 | |||||||||||||
| 74 | 4 | 1; | |||||||||||
| 75 | |||||||||||||
| 76 | # vim: set sw=4 ts=4: | ||||||||||||