| 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::IfExpr; |
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
13
|
use Moose; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
|
|
with 'Erlang::Parser::Node'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'seq' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]'); |
|
11
|
|
|
|
|
|
|
has 'stmts' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]'); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub print { |
|
14
|
8
|
|
|
8
|
1
|
12
|
my ($self, $fh, $depth) = @_; |
|
15
|
8
|
|
50
|
|
|
16
|
$depth ||= 0; |
|
16
|
|
|
|
|
|
|
|
|
17
|
8
|
|
|
|
|
10
|
my $first = 1; |
|
18
|
8
|
|
|
|
|
6
|
foreach (@{$self->seq}) { |
|
|
8
|
|
|
|
|
199
|
|
|
19
|
10
|
100
|
|
|
|
17
|
if ($first) { $first = 0 } else { print $fh ', ' } |
|
|
8
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
3
|
|
|
20
|
10
|
|
|
|
|
25
|
$_->print($fh, $depth); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
8
|
|
|
|
|
12
|
print $fh " ->\n"; |
|
23
|
|
|
|
|
|
|
|
|
24
|
8
|
|
|
|
|
7
|
$depth++; |
|
25
|
8
|
|
|
|
|
12
|
print $fh "\t" x $depth; |
|
26
|
|
|
|
|
|
|
|
|
27
|
8
|
|
|
|
|
9
|
$first = 1; |
|
28
|
8
|
|
|
|
|
9
|
foreach (@{$self->stmts}) { |
|
|
8
|
|
|
|
|
186
|
|
|
29
|
18
|
100
|
|
|
|
28
|
if ($first) { $first = 0 } else { print $fh ",\n", "\t" x $depth } |
|
|
8
|
|
|
|
|
9
|
|
|
|
10
|
|
|
|
|
15
|
|
|
30
|
18
|
|
|
|
|
43
|
$_->print($fh, $depth); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
8
|
|
|
|
|
18
|
$depth--; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Erlang::Parser::Node::IfExpr - a case in an if statement |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
A block of statements; a glorified parenthesis. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 Accessors |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=over 4 |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item C<seq> |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
The guard sequence; a list of L<Erlang::Parser::Node>s. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item C<exprs> |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
The body of L<Erlang::Parser::Node>s to be executed if C<seq> evalutes true. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 Methods |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=over 4 |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item C<print> |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Pretty-prints the node to its filehandle argument. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=back |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 EXAMPLE |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
X>Y -> |
|
72
|
|
|
|
|
|
|
true |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# vim: set sw=4 ts=4: |