File Coverage

blib/lib/Erlang/Parser/Node/FunRef.pm
Criterion Covered Total %
statement 10 10 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 2 2 100.0
pod 1 1 100.0
total 16 17 94.1


line stmt bran cond sub pod time code
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 3     3   12 use Moose;
  3         4  
  3         17  
8             with 'Erlang::Parser::Node';
9              
10             has 'module' => (is => 'rw', required => 0, isa => 'Maybe[Erlang::Parser::Node]');
11             has 'function' => (is => 'rw', required => 1, isa => 'Str');
12             has 'arity' => (is => 'rw', required => 1, isa => 'Int');
13              
14             sub print {
15 38     38 1 50 my ($self, $fh, $depth) = @_;
16 38   50     61 $depth ||= 0;
17              
18 38         63 print $fh 'fun ';
19              
20 38 100       968 if (defined $self->module) {
21 2         51 $self->module->print($fh, $depth);
22 2         5 print $fh ':';
23             }
24              
25 38         948 print $fh $self->function, '/', $self->arity;
26             }
27              
28             __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             1;
75              
76             # vim: set sw=4 ts=4: