line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lang::Tree::Builder::Data; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
26628
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
167
|
|
4
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
128
|
|
5
|
4
|
|
|
4
|
|
3684
|
use Lang::Tree::Builder::Class; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
1003
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Lang::Tree::Builder::Data - Tree Data |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Lang::Tree::Builder::Parser; |
17
|
|
|
|
|
|
|
my $parser = new Lang::Tree::Builder::Parser(); |
18
|
|
|
|
|
|
|
my $data = $parser->parseFile($datafile); |
19
|
|
|
|
|
|
|
foreach my $class ($data->classes()) { |
20
|
|
|
|
|
|
|
my $parent = $class->parent(); |
21
|
|
|
|
|
|
|
my @args = $class->args(); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 new |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $data = new Lang::Tree::Builder::Data; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Creates and returns a new instance of Data. Don't do this, the parser |
31
|
|
|
|
|
|
|
does it for you. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
36
|
2
|
|
|
2
|
1
|
17
|
my ($class) = @_; |
37
|
2
|
|
|
|
|
16
|
bless { |
38
|
|
|
|
|
|
|
classes => {}, |
39
|
|
|
|
|
|
|
}, $class; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 add |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$data->add($class); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
C<$class> is a C. Again the parser does this for you. |
47
|
|
|
|
|
|
|
The C<$data> object merely caches the class object. |
48
|
|
|
|
|
|
|
Note that this is only called for classes that are |
49
|
|
|
|
|
|
|
declared in the config, not for classes that are just mentioned as argument |
50
|
|
|
|
|
|
|
types for other constructors. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub add { |
55
|
2
|
|
|
2
|
1
|
5
|
my ($self, $class) = @_; |
56
|
2
|
|
|
|
|
12
|
$self->{classes}{$class->name} = $class; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 classes |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
returns an array of classes, or a reference to the same, sorted by name. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub classes { |
66
|
2
|
|
|
2
|
1
|
528
|
my ($self) = @_; |
67
|
2
|
|
|
|
|
5
|
my @classes = @{$self->{classes}}{sort keys %{$self->{classes}}}; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
10
|
|
68
|
2
|
50
|
|
|
|
11
|
return wantarray ? @classes : [@classes]; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 finalize |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
calls C on each cached class. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub finalize { |
78
|
2
|
|
|
2
|
1
|
6
|
my ($self) = @_; |
79
|
2
|
|
|
|
|
4
|
foreach my $key (keys %{$self->{classes}}) { |
|
2
|
|
|
|
|
10
|
|
80
|
2
|
|
|
|
|
16
|
$self->{classes}{$key}->substantiate(); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 SEE ALSO |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 AUTHOR |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Bill Hails, Eme@billhails.netE |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Copyright (C) 2008 by Bill Hails |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
97
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
98
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |