| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Lang::Tree::Builder::Args; |
|
2
|
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
30108
|
use strict; |
|
|
6
|
|
|
|
|
99
|
|
|
|
6
|
|
|
|
|
213
|
|
|
4
|
6
|
|
|
6
|
|
210
|
use warnings; |
|
|
6
|
|
|
|
|
12
|
|
|
|
6
|
|
|
|
|
159
|
|
|
5
|
6
|
|
|
6
|
|
586
|
use Lang::Tree::Builder::Class; |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
4826
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Lang::Tree::Builder::Args - wrapper for a tree node constructor's argument list. |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Lang::Tree::Builder::Args; |
|
14
|
|
|
|
|
|
|
my $ra_args = Lang::Tree::Builder::Args->List([ [$classname, $argname ] ... ]); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Used internally by C to encapsulate argument lists, |
|
17
|
|
|
|
|
|
|
a C object is a Decorator of the underlying |
|
18
|
|
|
|
|
|
|
C. It forwards all method requests to that class |
|
19
|
|
|
|
|
|
|
and adds an addidional C method returning the name of the |
|
20
|
|
|
|
|
|
|
argument. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _new { |
|
25
|
12
|
|
|
12
|
|
21
|
my ($class, $arg, $argname) = @_; |
|
26
|
12
|
|
|
|
|
76
|
bless { |
|
27
|
|
|
|
|
|
|
arg => $arg, |
|
28
|
|
|
|
|
|
|
argname => $argname, |
|
29
|
|
|
|
|
|
|
}, $class; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 List |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $list = Lang::Tree::Builder::Args->List(\@args); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
C<@args> is an array of array refs. Each array ref contains a string |
|
37
|
|
|
|
|
|
|
typename, and optionally a string varname, for example C<['Expr', 'left']>. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Returns a listref of C objects. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
If the argument name is omitted from the sub array component describing |
|
42
|
|
|
|
|
|
|
the argument, then the last part of the class namne will be used in its place. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Argument names will be sequentially numbered to avoid conflicts, but only |
|
45
|
|
|
|
|
|
|
if necessary. For example given the following call |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $ra_args = Lang::Tree::Builder::Args->List([ |
|
48
|
|
|
|
|
|
|
[qw(Foo::Expr)], |
|
49
|
|
|
|
|
|
|
[qw(Foo::Expr)], |
|
50
|
|
|
|
|
|
|
[qw(Foo::Expr foo)], |
|
51
|
|
|
|
|
|
|
[qw(Foo::Expr foo)], |
|
52
|
|
|
|
|
|
|
[qw(Foo::Expr bar)], |
|
53
|
|
|
|
|
|
|
[qw(Foo::ExprList)] |
|
54
|
|
|
|
|
|
|
]) |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
The resulting argument names will be: |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Expr1, Expr2, foo1, foo2, bar, ExprList |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub List { |
|
63
|
4
|
|
|
4
|
1
|
23
|
my ($class, $ra_args) = @_; |
|
64
|
12
|
|
|
|
|
51
|
my @classes = |
|
65
|
4
|
|
|
|
|
11
|
map { Lang::Tree::Builder::Class->new(class => $_->[0]) } @$ra_args; |
|
66
|
4
|
|
|
|
|
32
|
my %count; |
|
67
|
|
|
|
|
|
|
my %counter; |
|
68
|
12
|
100
|
|
|
|
61
|
my @protonames = |
|
69
|
4
|
|
|
|
|
15
|
map { $ra_args->[$_][1] || $classes[$_]->lastpart } |
|
70
|
|
|
|
|
|
|
(0 .. (scalar(@classes) - 1)); |
|
71
|
4
|
|
|
|
|
13
|
foreach my $arg (@protonames) { |
|
72
|
12
|
|
100
|
|
|
586
|
$count{$arg} ||= 0; |
|
73
|
12
|
|
|
|
|
17
|
$count{$arg}++; |
|
74
|
12
|
|
|
|
|
26
|
$counter{$arg} = 0; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
4
|
|
|
|
|
15
|
my @argnames; |
|
77
|
4
|
|
|
|
|
9
|
foreach my $arg (@protonames) { |
|
78
|
12
|
100
|
|
|
|
47
|
push @argnames, |
|
79
|
|
|
|
|
|
|
( |
|
80
|
|
|
|
|
|
|
$arg |
|
81
|
|
|
|
|
|
|
. ( |
|
82
|
|
|
|
|
|
|
$count{$arg} > 1 |
|
83
|
|
|
|
|
|
|
? ++$counter{$arg} |
|
84
|
|
|
|
|
|
|
: '' |
|
85
|
|
|
|
|
|
|
) |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
4
|
|
|
|
|
14
|
[ map { $class->_new($classes[$_], $argnames[$_]) } |
|
|
12
|
|
|
|
|
39
|
|
|
90
|
|
|
|
|
|
|
(0 .. (scalar(@classes) - 1)) ]; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# autoload interferes with tt2 |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub name { |
|
96
|
6
|
|
|
6
|
0
|
887
|
my ($self, @args) = @_; |
|
97
|
6
|
|
|
|
|
41
|
return $self->{arg}->name(@args); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub parent { |
|
101
|
0
|
|
|
0
|
0
|
0
|
my ($self, @args) = @_; |
|
102
|
0
|
|
|
|
|
0
|
return $self->{arg}->parent(@args); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub args { |
|
106
|
0
|
|
|
0
|
0
|
0
|
my ($self, @args) = @_; |
|
107
|
0
|
|
|
|
|
0
|
return $self->{arg}->args(@args); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub parts { |
|
111
|
0
|
|
|
0
|
0
|
0
|
my ($self, @args) = @_; |
|
112
|
0
|
|
|
|
|
0
|
return $self->{arg}->parts(@args); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub lastpart { |
|
116
|
0
|
|
|
0
|
0
|
0
|
my ($self, @args) = @_; |
|
117
|
0
|
|
|
|
|
0
|
return $self->{arg}->lastpart(@args); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub namespace { |
|
121
|
0
|
|
|
0
|
0
|
0
|
my ($self, @args) = @_; |
|
122
|
0
|
|
|
|
|
0
|
return $self->{arg}->namespace(@args); |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub interface { |
|
126
|
0
|
|
|
0
|
0
|
0
|
my ($self, @args) = @_; |
|
127
|
0
|
|
|
|
|
0
|
return $self->{arg}->namespace(@args); |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub is_scalar { |
|
131
|
0
|
|
|
0
|
0
|
0
|
my ($self, @args) = @_; |
|
132
|
0
|
|
|
|
|
0
|
return $self->{arg}->is_scalar(@args); |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub is_substantial { |
|
136
|
0
|
|
|
0
|
0
|
0
|
my ($self, @args) = @_; |
|
137
|
0
|
|
|
|
|
0
|
return $self->{arg}->is_substantial(@args); |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub argname { |
|
141
|
12
|
|
|
12
|
0
|
38
|
my ($self) = @_; |
|
142
|
12
|
|
|
|
|
55
|
return $self->{argname}; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Bill Hails |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L, L. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
1; |