develooper Front page | perl.perl5.porters | Postings from January 2001

[PATCH @8344] Fix spurious GVSV OPpOUR_INTRO

Thread Next
Stephen McCamant
January 6, 2001 15:25
[PATCH @8344] Fix spurious GVSV OPpOUR_INTRO
Message ID:
The most common way for package variables is that first the word part
of the variable (the foo in '$foo') is tokenized as an OP_CONST; then
the $ is parsed into an OP_RV2SV, whose check routine looks up the
constant and turns it into an OP_GV. Finally, in peep(), the sequence
of a gv followed an rv2sv is often changed into an OP_GVSV.

The OP_CONST usually has the OPpCONST_ENTERED private flag set,
indicating that the tokenizer has already but it in the symbol table,
and at the moment the private flags of the const are retained when
it's turned into a gv. Later, when the gvsv is created, its private
flags are set to the union of (some of) the rv2sv's flags and the gv's
flags. At this point, the numeric value (16) of OPpCONST_ENTERED makes 
it turn into an OPpOUR_INTRO, which makes every gvsv appear to have
been in an `our()' declaration. (OP_GVSVs can also get a legitimate
OPpOUR_INTRO, but that comes from the rv2sv). Since the OPpOUR_INTRO
is currently only examined during compilation phases prior to peek(),
this spurious flag doesn't have any ill effects, but it could be
problematic for future changes (for instance, recognizing our()
declarations in B::Deparse).

The following patch clears the OP_CONST's private flags when it turns
into an OP_GV, and fixes an omission in -Dx that made the private
flags of OP_GVSVs invisible.

 -- Stephen McC

--- perl-current/op.c	Fri Jan  5 00:44:57 2001
+++ perl-changed/op.c	Sat Jan  6 17:00:44 2001
@@ -5451,6 +5451,7 @@ Perl_ck_rvconst(pTHX_ register OP *o)
 	    kid->op_sv = SvREFCNT_inc(gv);
+	    kid->op_private = 0;
 	    kid->op_ppaddr = PL_ppaddr[OP_GV];
--- perl-current/dump.c	Sun Dec 31 18:02:30 2000
+++ perl-changed/dump.c	Sat Jan  6 17:12:14 2001
@@ -455,6 +455,7 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO 
 	else if (o->op_type == OP_ENTERSUB ||
 		 o->op_type == OP_RV2SV ||
+		 o->op_type == OP_GVSV ||
 		 o->op_type == OP_RV2AV ||
 		 o->op_type == OP_RV2HV ||
 		 o->op_type == OP_RV2GV ||

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About