From: Malcolm Beattie Date: Sat, 5 Jul 1997 11:58:05 +0000 (+0000) Subject: B::CC::pp_padsv must cope with vivify_ref (5.004) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3266387ebfb1f114b616b6213bd8261ac0d66e48;p=p5sagit%2Fp5-mst-13.2.git B::CC::pp_padsv must cope with vivify_ref (5.004) as well as provide_ref (5.003). p4raw-id: //depot/perlext/Compiler@36 --- diff --git a/B/C.pm b/B/C.pm index 78c80e7..39cbb49 100644 --- a/B/C.pm +++ b/B/C.pm @@ -939,6 +939,10 @@ extern "C" { #undef pp_mapstart #define pp_mapstart pp_grepstart +#if PATCHLEVEL < 4 +#define vivify_ref(sv, to_what) provide_ref(op, sv) +#endif + static void xs_init _((void)); static PerlInterpreter *my_perl; EOT diff --git a/B/CC.pm b/B/CC.pm index 68287d0..25956dd 100644 --- a/B/CC.pm +++ b/B/CC.pm @@ -26,6 +26,7 @@ sub OPpASSIGN_BACKWARDS () { 64 } sub OPpLVAL_INTRO () { 128 } sub OPpDEREF_AV () { 32 } sub OPpDEREF_HV () { 64 } +sub OPpDEREF () { OPpDEREF_AV|OPpDEREF_HV } sub OPpFLIP_LINENUM () { 64 } sub G_ARRAY () { 1 } # cop.h @@ -88,6 +89,8 @@ my ($freetmps_each_bblock, $freetmps_each_loop, $omit_taint); my %optimise = (freetmps_each_bblock => \$freetmps_each_bblock, freetmps_each_loop => \$freetmps_each_loop, omit_taint => \$omit_taint); +# perl patchlevel to generate code for (defaults to current patchlevel) +my $patchlevel = int(0.5 + 1000 * ($] - 5)); # Could rewrite push_runtime() and output_runtime() to use a # temporary file if memory is at a premium. @@ -540,9 +543,10 @@ sub pp_padsv { my $private = $op->private; if ($private & OPpLVAL_INTRO) { runtime("SAVECLEARSV(curpad[$ix]);"); - } elsif ($private & (OPpDEREF_HV|OPpDEREF_AV)) { - loadop($op); - runtime("provide_ref(op, curpad[$ix]);"); + } elsif ($private & OPpDEREF) { + loadop($op) if $patchlevel < 4; + runtime(sprintf("vivify_ref(curpad[%d], %d);", + $ix, $private & OPpDEREF)); $pad[$ix]->invalidate; } } @@ -1468,6 +1472,9 @@ sub compile { $arg ||= shift @options; $module = $arg; push(@unused_sub_packages, $arg); + } elsif ($opt eq "p") { + $arg ||= shift @options; + $patchlevel = $arg; } elsif ($opt eq "D") { $arg ||= shift @options; foreach $arg (split(//, $arg)) { diff --git a/NOTES b/NOTES index c1ddbc6..7640e54 100644 --- a/NOTES +++ b/NOTES @@ -51,6 +51,10 @@ CC backend invocation boot_Modulename function (which DynaLoader can look for) does the appropriate initialisation and runs the main part of the Perl source that is being compiled. + -pn Generate code for perl patchlevel n (e.g. 3 or 4). + The default is to generate C code which will link + with the currently executing version of perl. + running the perl compiler. -D Debug options (concat or separate flags like perl -D) r Writes debugging output to STDERR just as it's about to write to the program's runtime (otherwise writes