File Coverage

blib/lib/Erlang/Parser/Node/Call.pm
Criterion Covered Total %
statement 20 20 100.0
branch 8 8 100.0
condition 2 2 100.0
subroutine 2 2 100.0
pod 1 1 100.0
total 33 33 100.0


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::Call;
6              
7 3     3   11 use Moose;
  3         3  
  3         12  
8             with 'Erlang::Parser::Node';
9              
10             has 'module' => (is => 'rw', required => 0, isa => 'Erlang::Parser::Node');
11             has 'function' => (is => 'rw', required => 1, isa => 'Erlang::Parser::Node');
12             has 'args' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]');
13              
14             sub print {
15 6828     6828 1 6332 my ($self, $fh, $depth) = @_;
16 6828   100     9286 $depth ||= 0;
17              
18 6828 100       162921 if (defined $self->module) {
19 1802         41826 $self->module->print($fh, $depth);
20 1802         2603 print $fh ':';
21             }
22              
23 6828 100       160647 print $fh '(' if $self->function->blessed ne 'Erlang::Parser::Node::Atom';
24 6828         160962 $self->function->print($fh, $depth);
25 6828 100       160861 print $fh ')' if $self->function->blessed ne 'Erlang::Parser::Node::Atom';
26 6828         9249 print $fh '(';
27 6828         6533 my $first = 1;
28 6828         4643 foreach (@{$self->args}) {
  6828         161022  
29 11272 100       13653 if ($first) { $first = 0 } else { print $fh ', ' }
  6678         5426  
  4594         4799  
30 11272         23674 $_->print($fh, $depth);
31             }
32 6828         13290 print $fh ')';
33             }
34              
35             __PACKAGE__->meta->make_immutable;
36              
37             =head1 NAME
38              
39             Erlang::Parser::Node::Call - a function call
40              
41             =head1 DESCRIPTION
42              
43             A call to a function, either local or external.
44              
45             =head2 Accessors
46              
47             =over 4
48              
49             =item C<module>
50              
51             A L<Erlang::Parser::Node> which returns the name of the module to use as an
52             atom; or C<undef>.
53              
54             =item C<function>
55              
56             A L<Erlang::Parser::Node> which either returns an atom which corresponds to a
57             local function or a function in C<module> if specified; or which returns a
58             calculated fun or fun reference itself.
59              
60             =item C<args>
61              
62             A list of L<Erlang::Parser::Node>s which are passed as arguments to the
63             function.
64              
65             =back
66              
67             =head2 Methods
68              
69             =over 4
70              
71             =item C<print>
72              
73             Pretty-prints the node to its filehandle argument.
74              
75             =back
76              
77             =head1 EXAMPLE
78              
79             lists:reverse([1, 2, 3])
80              
81             =cut
82              
83             1;
84              
85             # vim: set sw=4 ts=4: