diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-10-03 05:19:56 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-10-03 05:19:56 +0000 |
commit | 78ca652eaf12f3ab6d7714883eec614d257f666a (patch) | |
tree | 6bbe81a261abeb34caf5651b686d45f2eb395c5f /op.c | |
parent | 39e216bc90d449c29ecedac1a04e0b8d579b806c (diff) | |
download | perl-78ca652eaf12f3ab6d7714883eec614d257f666a.tar.gz |
make C<use> recognize C<require> overrides; allow C<do EXPR> to be
overridden
p4raw-id: //depot/perl@1923
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 41 |
1 files changed, 39 insertions, 2 deletions
@@ -2580,6 +2580,7 @@ utilize(int aver, I32 floor, OP *version, OP *id, OP *arg) OP *rqop; OP *imop; OP *veop; + GV *gv; if (id->op_type != OP_CONST) croak("Module name must be constant"); @@ -2631,8 +2632,21 @@ utilize(int aver, I32 floor, OP *version, OP *id, OP *arg) newUNOP(OP_METHOD, 0, meth))); } - /* Fake up a require */ - rqop = newUNOP(OP_REQUIRE, 0, id); + /* Fake up a require, handle override, if any */ + gv = gv_fetchpv("require", FALSE, SVt_PVCV); + if (!(gv && GvIMPORTED_CV(gv))) + gv = gv_fetchpv("CORE::GLOBAL::require", FALSE, SVt_PVCV); + + if (gv && GvIMPORTED_CV(gv)) { + rqop = ck_subr(newUNOP(OP_ENTERSUB, OPf_STACKED, + append_elem(OP_LIST, id, + scalar(newUNOP(OP_RV2CV, 0, + newGVOP(OP_GV, 0, + gv)))))); + } + else { + rqop = newUNOP(OP_REQUIRE, 0, id); + } /* Fake up the BEGIN {}, which does its thing immediately. */ newSUB(floor, @@ -2649,6 +2663,29 @@ utilize(int aver, I32 floor, OP *version, OP *id, OP *arg) } OP * +dofile(OP *term) +{ + OP *doop; + GV *gv; + + gv = gv_fetchpv("do", FALSE, SVt_PVCV); + if (!(gv && GvIMPORTED_CV(gv))) + gv = gv_fetchpv("CORE::GLOBAL::do", FALSE, SVt_PVCV); + + if (gv && GvIMPORTED_CV(gv)) { + doop = ck_subr(newUNOP(OP_ENTERSUB, OPf_STACKED, + append_elem(OP_LIST, term, + scalar(newUNOP(OP_RV2CV, 0, + newGVOP(OP_GV, 0, + gv)))))); + } + else { + doop = newUNOP(OP_DOFILE, 0, scalar(term)); + } + return doop; +} + +OP * newSLICEOP(I32 flags, OP *subscript, OP *listval) { return newBINOP(OP_LSLICE, flags, |