Bareword sub lookups
authorZefram <zefram@fysh.org>
Sun, 8 Nov 2009 14:03:45 +0000 (15:03 +0100)
committerRafael Garcia-Suarez <rgs@consttype.org>
Sun, 8 Nov 2009 14:11:11 +0000 (15:11 +0100)
commitf7461760003db2ce68155c97ea6c1658e96fcd27
tree3ef60fff1e3763bb814eb07f408a34688546c026
parent6bd7445c6d3b53823883c456e32ea27ce24bfc5c
Bareword sub lookups

Attached is a patch that changes how the tokeniser looks up subroutines,
when they're referenced by a bareword, for prototype and const-sub
purposes.  Formerly, it has looked up bareword subs directly in the
package, which is contrary to the way the generated op tree looks up
the sub, via an rv2cv op.  The patch makes the tokeniser generate the
rv2cv op earlier, and dig around in that.

The motivation for this is to allow modules to hook the rv2cv op
creation, to affect the name->subroutine lookup process.  Currently,
such hooking affects op execution as intended, but everything goes wrong
with a bareword ref where the tokeniser looks at some unrelated CV,
or a blank space, in the package.  With the patch in place, an rv2cv
hook correctly affects the tokeniser and therefore the prototype-based
aspects of parsing.

The patch also changes ck_subr (which applies the argument context and
checking parts of prototype behaviour) to handle subs referenced by an
RV const op inside the rv2cv, where formerly it would only handle a gv
op inside the rv2cv.  This is to support the most likely kind of
modified rv2cv op.

The attached patch is the resulting revised version of the bareword
sub patch.  It incorporates the original patch (allowing rv2cv op
hookers to control prototype processing), the GV-downgrading addition,
and a mention in perldelta.
embed.fnc
embed.h
global.sym
gv.c
op.c
pod/perl5112delta.pod
proto.h
toke.c