#define PL_bitcount (PERL_GET_INTERP->Ibitcount)
#define PL_bufend (PERL_GET_INTERP->Ibufend)
#define PL_bufptr (PERL_GET_INTERP->Ibufptr)
+#define PL_checkav (PERL_GET_INTERP->Icheckav)
#define PL_collation_ix (PERL_GET_INTERP->Icollation_ix)
#define PL_collation_name (PERL_GET_INTERP->Icollation_name)
#define PL_collation_standard (PERL_GET_INTERP->Icollation_standard)
#define PL_statusvalue_vms (PERL_GET_INTERP->Istatusvalue_vms)
#define PL_stderrgv (PERL_GET_INTERP->Istderrgv)
#define PL_stdingv (PERL_GET_INTERP->Istdingv)
-#define PL_stopav (PERL_GET_INTERP->Istopav)
#define PL_strtab (PERL_GET_INTERP->Istrtab)
#define PL_strtab_mutex (PERL_GET_INTERP->Istrtab_mutex)
#define PL_sub_generation (PERL_GET_INTERP->Isub_generation)
#define PL_bitcount (vTHX->Ibitcount)
#define PL_bufend (vTHX->Ibufend)
#define PL_bufptr (vTHX->Ibufptr)
+#define PL_checkav (vTHX->Icheckav)
#define PL_collation_ix (vTHX->Icollation_ix)
#define PL_collation_name (vTHX->Icollation_name)
#define PL_collation_standard (vTHX->Icollation_standard)
#define PL_statusvalue_vms (vTHX->Istatusvalue_vms)
#define PL_stderrgv (vTHX->Istderrgv)
#define PL_stdingv (vTHX->Istdingv)
-#define PL_stopav (vTHX->Istopav)
#define PL_strtab (vTHX->Istrtab)
#define PL_strtab_mutex (vTHX->Istrtab_mutex)
#define PL_sub_generation (vTHX->Isub_generation)
#define PL_bitcount (aTHXo->interp.Ibitcount)
#define PL_bufend (aTHXo->interp.Ibufend)
#define PL_bufptr (aTHXo->interp.Ibufptr)
+#define PL_checkav (aTHXo->interp.Icheckav)
#define PL_collation_ix (aTHXo->interp.Icollation_ix)
#define PL_collation_name (aTHXo->interp.Icollation_name)
#define PL_collation_standard (aTHXo->interp.Icollation_standard)
#define PL_statusvalue_vms (aTHXo->interp.Istatusvalue_vms)
#define PL_stderrgv (aTHXo->interp.Istderrgv)
#define PL_stdingv (aTHXo->interp.Istdingv)
-#define PL_stopav (aTHXo->interp.Istopav)
#define PL_strtab (aTHXo->interp.Istrtab)
#define PL_strtab_mutex (aTHXo->interp.Istrtab_mutex)
#define PL_sub_generation (aTHXo->interp.Isub_generation)
#define PL_Ibitcount PL_bitcount
#define PL_Ibufend PL_bufend
#define PL_Ibufptr PL_bufptr
+#define PL_Icheckav PL_checkav
#define PL_Icollation_ix PL_collation_ix
#define PL_Icollation_name PL_collation_name
#define PL_Icollation_standard PL_collation_standard
#define PL_Istatusvalue_vms PL_statusvalue_vms
#define PL_Istderrgv PL_stderrgv
#define PL_Istdingv PL_stdingv
-#define PL_Istopav PL_stopav
#define PL_Istrtab PL_strtab
#define PL_Istrtab_mutex PL_strtab_mutex
#define PL_Isub_generation PL_sub_generation
BEGIN { %Seen = %INC }
-STOP {
+CHECK {
my @arr=scan($main::{"main::"});
@arr=map{s/\:\:$//;$_;} @arr;
print "-umain,-u", join (",-u",@arr) ,"\n";
it should return a sub ref (usually a closure) to perform the
actual compilation. When O regains control, it ensures that the
"-c" option is forced (so that the program being compiled doesn't
- end up running) and registers a STOP block to call back the sub ref
+ end up running) and registers a CHECK block to call back the sub ref
returned from the backend's compile(). Perl then continues by
parsing prog.pl (just as it would with "perl -c prog.pl") and after
- doing so, assuming there are no parse-time errors, the STOP block
+ doing so, assuming there are no parse-time errors, the CHECK block
of O gets called and the actual backend compilation happens. Phew.
my $compilesub = &{"B::${backend}::compile"}(@options);
if (ref($compilesub) eq "CODE") {
minus_c;
- eval 'STOP { &$compilesub() }';
+ eval 'CHECK { &$compilesub() }';
} else {
die $compilesub;
}
package, passing it OPTIONS. That function is expected to return
a sub reference which we'll call CALLBACK. Next, the "compile-only"
flag is switched on (equivalent to the command-line option C<-c>)
-and a STOP block is registered which calls CALLBACK. Thus the main
+and a CHECK block is registered which calls CALLBACK. Thus the main
Perl program mentioned on the command-line is read in, parsed and
compiled into internal syntax tree form. Since the C<-c> flag is
set, the program does not start running (excepting BEGIN blocks of
PERLVAR(Icurstname, SV *) /* name of current package */
PERLVAR(Ibeginav, AV *) /* names of BEGIN subroutines */
PERLVAR(Iendav, AV *) /* names of END subroutines */
-PERLVAR(Istopav, AV *) /* names of STOP subroutines */
+PERLVAR(Icheckav, AV *) /* names of CHECK subroutines */
PERLVAR(Iinitav, AV *) /* names of INIT subroutines */
PERLVAR(Istrtab, HV *) /* shared string table */
PERLVARI(Isub_generation,U32,1) /* incr to invalidate method cache */
#define KEY_LE 15
#define KEY_LT 16
#define KEY_NE 17
-#define KEY_STOP 18
+#define KEY_CHECK 18
#define KEY_abs 19
#define KEY_accept 20
#define KEY_alarm 21
LE
LT
NE
-STOP
+CHECK
abs
accept
alarm
#=======================================================================
# Some names are evil choices.
-my %keywords = map +($_, 1), qw{ BEGIN INIT STOP END DESTROY AUTOLOAD };
+my %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD };
my %forced_into_main = map +($_, 1),
qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG };
else
s = name;
- if (*s != 'B' && *s != 'E' && *s != 'S' && *s != 'I')
+ if (*s != 'B' && *s != 'E' && *s != 'C' && *s != 'I')
goto done;
if (strEQ(s, "BEGIN")) {
av_store(PL_endav, 0, SvREFCNT_inc(cv));
GvCV(gv) = 0;
}
- else if (strEQ(s, "STOP") && !PL_error_count) {
- if (!PL_stopav)
- PL_stopav = newAV();
+ else if (strEQ(s, "CHECK") && !PL_error_count) {
+ if (!PL_checkav)
+ PL_checkav = newAV();
DEBUG_x( dump_sub(gv) );
- av_unshift(PL_stopav, 1);
- av_store(PL_stopav, 0, SvREFCNT_inc(cv));
+ av_unshift(PL_checkav, 1);
+ av_store(PL_checkav, 0, SvREFCNT_inc(cv));
GvCV(gv) = 0;
}
else if (strEQ(s, "INIT") && !PL_error_count) {
else
s = name;
- if (*s != 'B' && *s != 'E' && *s != 'S' && *s != 'I')
+ if (*s != 'B' && *s != 'E' && *s != 'C' && *s != 'I')
goto done;
if (strEQ(s, "BEGIN")) {
av_store(PL_endav, 0, SvREFCNT_inc(cv));
GvCV(gv) = 0;
}
- else if (strEQ(s, "STOP")) {
- if (!PL_stopav)
- PL_stopav = newAV();
- av_unshift(PL_stopav, 1);
- av_store(PL_stopav, 0, SvREFCNT_inc(cv));
+ else if (strEQ(s, "CHECK")) {
+ if (!PL_checkav)
+ PL_checkav = newAV();
+ av_unshift(PL_checkav, 1);
+ av_store(PL_checkav, 0, SvREFCNT_inc(cv));
GvCV(gv) = 0;
}
else if (strEQ(s, "INIT")) {
/* startup and shutdown function lists */
SvREFCNT_dec(PL_beginav);
SvREFCNT_dec(PL_endav);
- SvREFCNT_dec(PL_stopav);
+ SvREFCNT_dec(PL_checkav);
SvREFCNT_dec(PL_initav);
PL_beginav = Nullav;
PL_endav = Nullav;
- PL_stopav = Nullav;
+ PL_checkav = Nullav;
PL_initav = Nullav;
/* shortcuts just get cleared */
env, xsinit);
switch (ret) {
case 0:
- if (PL_stopav)
- call_list(oldscope, PL_stopav);
+ if (PL_checkav)
+ call_list(oldscope, PL_checkav);
return 0;
case 1:
STATUS_ALL_FAILURE;
LEAVE;
FREETMPS;
PL_curstash = PL_defstash;
- if (PL_stopav)
- call_list(oldscope, PL_stopav);
+ if (PL_checkav)
+ call_list(oldscope, PL_checkav);
return STATUS_NATIVE_EXPORT;
case 3:
PerlIO_printf(Perl_error_log, "panic: top_env\n");
else
Perl_sv_catpvf(aTHX_ atsv,
"%s failed--call queue aborted",
- paramList == PL_stopav ? "STOP"
+ paramList == PL_checkav ? "CHECK"
: paramList == PL_initav ? "INIT"
: "END");
while (PL_scopestack_ix > oldscope)
Perl_croak(aTHX_ "BEGIN failed--compilation aborted");
else
Perl_croak(aTHX_ "%s failed--call queue aborted",
- paramList == PL_stopav ? "STOP"
+ paramList == PL_checkav ? "CHECK"
: paramList == PL_initav ? "INIT"
: "END");
}
#define PL_bufend (*Perl_Ibufend_ptr(aTHXo))
#undef PL_bufptr
#define PL_bufptr (*Perl_Ibufptr_ptr(aTHXo))
+#undef PL_checkav
+#define PL_checkav (*Perl_Icheckav_ptr(aTHXo))
#undef PL_collation_ix
#define PL_collation_ix (*Perl_Icollation_ix_ptr(aTHXo))
#undef PL_collation_name
#define PL_stderrgv (*Perl_Istderrgv_ptr(aTHXo))
#undef PL_stdingv
#define PL_stdingv (*Perl_Istdingv_ptr(aTHXo))
-#undef PL_stopav
-#define PL_stopav (*Perl_Istopav_ptr(aTHXo))
#undef PL_strtab
#define PL_strtab (*Perl_Istrtab_ptr(aTHXo))
#undef PL_strtab_mutex
#line 338 "perly.y"
{ STRLEN n_a; char *name = SvPV(((SVOP*)yyvsp[0].opval)->op_sv,n_a);
if (strEQ(name, "BEGIN") || strEQ(name, "END")
- || strEQ(name, "STOP") || strEQ(name, "INIT"))
+ || strEQ(name, "INIT") || strEQ(name, "CHECK"))
CvSPECIAL_on(PL_compcv);
yyval.opval = yyvsp[0].opval; }
break;
subname : WORD { STRLEN n_a; char *name = SvPV(((SVOP*)$1)->op_sv,n_a);
if (strEQ(name, "BEGIN") || strEQ(name, "END")
- || strEQ(name, "STOP") || strEQ(name, "INIT"))
+ || strEQ(name, "INIT") || strEQ(name, "CHECK"))
CvSPECIAL_on(PL_compcv);
$$ = $1; }
;
=over 4
-=item STOP is a new keyword
+=item CHECK is a new keyword
In addition to C<BEGIN>, C<INIT>, C<END>, C<DESTROY> and C<AUTOLOAD>,
-subroutines named C<STOP> are now special. These are queued up during
+subroutines named C<CHECK> are now special. These are queued up during
compilation and behave similar to END blocks, except they are called at
the end of compilation rather than at the end of execution. They cannot
be called directly.
behavior, END blocks are not executed anymore when the C<-c> switch
is used.
-See L<STOP blocks> for how to run things when the compile phase ends.
+See L<CHECK blocks> for how to run things when the compile phase ends.
=head2 Potential to leak DATA filehandles
=item %s failed--call queue aborted
-(F) An untrapped exception was raised while executing a STOP, INIT, or
+(F) An untrapped exception was raised while executing a CHECK, INIT, or
END subroutine. Processing of the remainder of the queue of such
routines has been prematurely ended.
array, returns the undefined value. If ARRAY is omitted, shifts the
C<@_> array within the lexical scope of subroutines and formats, and the
C<@ARGV> array at file scopes or within the lexical scopes established by
-the C<eval ''>, C<BEGIN {}>, C<INIT {}>, C<STOP {}>, and C<END {}>
+the C<eval ''>, C<BEGIN {}>, C<INIT {}>, C<CHECK {}>, and C<END {}>
constructs.
See also C<unshift>, C<push>, and C<pop>. C<Shift()> and C<unshift> do the
=head2 Package Constructors and Destructors
Four special subroutines act as package constructors and destructors.
-These are the C<BEGIN>, C<STOP>, C<INIT>, and C<END> routines. The
+These are the C<BEGIN>, C<CHECK>, C<INIT>, and C<END> routines. The
C<sub> is optional for these routines.
A C<BEGIN> subroutine is executed as soon as possible, that is, the moment
For example, the code generators documented in L<perlcc> make use of
C<INIT> blocks to initialize and resolve pointers to XSUBs.
-Similar to C<END> blocks, C<STOP> blocks are run just after the
+Similar to C<END> blocks, C<CHECK> blocks are run just after the
Perl compile phase ends and before the run time begins, in
-LIFO order. C<STOP> blocks are again useful in the Perl compiler
+LIFO order. C<CHECK> blocks are again useful in the Perl compiler
suite to save the compiled state of the program.
When you use the B<-n> and B<-p> switches to Perl, C<BEGIN> and
=item B<-c>
causes Perl to check the syntax of the program and then exit without
-executing it. Actually, it I<will> execute C<BEGIN>, C<STOP>, and
+executing it. Actually, it I<will> execute C<BEGIN>, C<CHECK>, and
C<use> blocks, because these are considered as occurring outside the
execution of your program. C<INIT> and C<END> blocks, however, will
be skipped.
function in all capitals is a loosely-held convention meaning it
will be called indirectly by the run-time system itself, usually
due to a triggered event. Functions that do special, pre-defined
-things include C<BEGIN>, C<STOP>, C<INIT>, C<END>, C<AUTOLOAD>, and
+things include C<BEGIN>, C<CHECK>, C<INIT>, C<END>, C<AUTOLOAD>, and
C<DESTROY>--plus all functions mentioned in L<perltie>.
=head2 Private Variables via my()
}
See L<perlmod/"Package Constructors and Destructors"> about the
-special triggered functions, C<BEGIN>, C<STOP>, C<INIT> and C<END>.
+special triggered functions, C<BEGIN>, C<CHECK>, C<INIT> and C<END>.
If declared at the outermost scope (the file scope), then lexicals
work somewhat like C's file statics. They are available to all
=head2 END blocks
-END blocks need saving in compiled output, now that STOP blocks
+END blocks need saving in compiled output, now that CHECK blocks
are available.
=head2 _AUTOLOAD
PL_beginav = av_dup_inc(proto_perl->Ibeginav);
PL_endav = av_dup_inc(proto_perl->Iendav);
- PL_stopav = av_dup_inc(proto_perl->Istopav);
+ PL_checkav = av_dup_inc(proto_perl->Icheckav);
PL_initav = av_dup_inc(proto_perl->Iinitav);
PL_sub_generation = proto_perl->Isub_generation;
BEGIN { print "argv <@ARGV>\nbegin <",shift,">\n" }
END { print "end <",shift,">\nargv <@ARGV>\n" }
INIT { print "init <",shift,">\n" }
-STOP { print "stop <",shift,">\n" }
+CHECK { print "check <",shift,">\n" }
EXPECT
argv <a b c d e>
begin <a>
-stop <b>
+check <b>
init <c>
end <d>
argv <e>
case KEY_AUTOLOAD:
case KEY_DESTROY:
case KEY_BEGIN:
- case KEY_END:
- case KEY_STOP:
+ case KEY_CHECK:
case KEY_INIT:
+ case KEY_END:
if (PL_expect == XSTATE) {
s = PL_bufptr;
goto really_sub;
break;
case 'C':
if (strEQ(d,"CORE")) return -KEY_CORE;
+ if (strEQ(d,"CHECK")) return KEY_CHECK;
break;
case 'c':
switch (len) {
break;
}
break;
- case 'S':
- if (strEQ(d,"STOP")) return KEY_STOP;
- break;
case 's':
switch (d[1]) {
case 0: return KEY_s;
#line 338 "perly.y"
{ STRLEN n_a; char *name = SvPV(((SVOP*)yyvsp[0].opval)->op_sv,n_a);
if (strEQ(name, "BEGIN") || strEQ(name, "END")
- || strEQ(name, "STOP") || strEQ(name, "INIT"))
+ || strEQ(name, "INIT") || strEQ(name, "CHECK"))
CvSPECIAL_on(PL_compcv);
yyval.opval = yyvsp[0].opval; }
break;