line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PPI::Statement::Scheduled; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
PPI::Statement::Scheduled - A scheduled code block |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 INHERITANCE |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
PPI::Statement::Scheduled |
12
|
|
|
|
|
|
|
isa PPI::Statement::Sub |
13
|
|
|
|
|
|
|
isa PPI::Statement |
14
|
|
|
|
|
|
|
isa PPI::Node |
15
|
|
|
|
|
|
|
isa PPI::Element |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
A scheduled code block is one that is intended to be run at a specific |
20
|
|
|
|
|
|
|
time during the loading process. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
There are five types of scheduled block: |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
BEGIN { |
25
|
|
|
|
|
|
|
# Executes as soon as this block is fully defined |
26
|
|
|
|
|
|
|
... |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
CHECK { |
30
|
|
|
|
|
|
|
# Executes after overall compile-phase in reverse order |
31
|
|
|
|
|
|
|
... |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
UNITCHECK { |
35
|
|
|
|
|
|
|
# Executes after compile-phase of individual module in reverse order |
36
|
|
|
|
|
|
|
... |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
INIT { |
40
|
|
|
|
|
|
|
# Executes just before run-time |
41
|
|
|
|
|
|
|
... |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
END { |
45
|
|
|
|
|
|
|
# Executes as late as possible in reverse order |
46
|
|
|
|
|
|
|
... |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Technically these scheduled blocks are actually subroutines, and in fact |
50
|
|
|
|
|
|
|
may have 'sub' in front of them. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 METHODS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
64
|
|
|
64
|
|
371
|
use strict; |
|
64
|
|
|
|
|
136
|
|
|
64
|
|
|
|
|
1490
|
|
57
|
64
|
|
|
64
|
|
22304
|
use PPI::Statement::Sub (); |
|
64
|
|
|
|
|
148
|
|
|
64
|
|
|
|
|
9746
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
our $VERSION = '1.276'; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
our @ISA = "PPI::Statement::Sub"; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub __LEXER__normal() { '' } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _complete { |
66
|
0
|
|
|
0
|
|
0
|
my $child = $_[0]->schild(-1); |
67
|
|
|
|
|
|
|
return !! ( |
68
|
0
|
|
0
|
|
|
0
|
defined $child |
69
|
|
|
|
|
|
|
and |
70
|
|
|
|
|
|
|
$child->isa('PPI::Structure::Block') |
71
|
|
|
|
|
|
|
and |
72
|
|
|
|
|
|
|
$child->complete |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=pod |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 type |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
The C method returns the type of scheduled block, which should always be |
81
|
|
|
|
|
|
|
one of C<'BEGIN'>, C<'CHECK'>, C<'UNITCHECK'>, C<'INIT'> or C<'END'>. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub type { |
86
|
85
|
|
|
85
|
1
|
227
|
my $self = shift; |
87
|
85
|
50
|
|
|
|
195
|
my @children = $self->schildren or return undef; |
88
|
85
|
100
|
|
|
|
220
|
$children[0]->content eq 'sub' |
89
|
|
|
|
|
|
|
? $children[1]->content |
90
|
|
|
|
|
|
|
: $children[0]->content; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# This is actually the same as Sub->name |
94
|
|
|
|
|
|
|
sub name { |
95
|
85
|
|
|
85
|
1
|
193
|
shift->type(@_); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=pod |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 TO DO |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
- Write unit tests for this package |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SUPPORT |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
See the L in the main module. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 AUTHOR |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Adam Kennedy Eadamk@cpan.orgE |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 COPYRIGHT |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Copyright 2001 - 2011 Adam Kennedy. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This program is free software; you can redistribute |
119
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
The full text of the license can be found in the |
122
|
|
|
|
|
|
|
LICENSE file included with this module. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |