Skip to content

Commit

Permalink
move !$$root method not found case upwards
Browse files Browse the repository at this point in the history
remove is only needed for the last idx.
think I fixed remove for intermediate also, but this path
is never called.
all tests but 15 pass
  • Loading branch information
Reini Urban committed Feb 13, 2012
1 parent c6dbeb2 commit 7883eda
Showing 1 changed file with 53 additions and 54 deletions.
107 changes: 53 additions & 54 deletions lib/B/C.pm
Expand Up @@ -36,8 +36,8 @@ sub add {

sub remove {
my $section = shift;
if (@_) {
splice @{ $section->[-1]{values} }, shift, 1;
if (@_) { # XXX
splice @{ $section }, shift, 1;
} else {
pop @{ $section->[-1]{values} };
}
Expand Down Expand Up @@ -2722,69 +2722,68 @@ sub B::CV::save {
}
}
}
if (!$$root) {
warn "WARNING: &".$fullname." not found\n" if $verbose or $debug{sub};
warn "No definition for sub $fullname (unable to autoload), remove cv\n"
if $debug{cv};
$init->add( "/* $fullname not found */" ) if $verbose or $debug{sub};
# Empty CV (methods) must be skipped not to disturb method resolution
$svsect->remove; #( $sv_ix );
$xpvcvsect->remove; #( $xpvcv_ix );
delsym( $cv );
#return svref_2object( \&Dummy_initxs )->save;
return '0';
}

my $startfield = 0;
my $padlist = $cv->PADLIST;
my $padlistsym = 'NULL';
my $pv = $cv->PV;
my $xsub = 0;
my $xsubany = "Nullany";
if ($$root) {
warn sprintf( "saving op tree for CV 0x%x, root=0x%x\n",
$$cv, $$root )
if $debug{cv} and $debug{gv};
my $ppname = "";
if ($$gv) {
my $stashname = $gv->STASH->NAME;
my $gvname = $gv->NAME;
$fullname = $stashname.'::'.$gvname;
if ( $gvname ne "__ANON__" ) {
$ppname = ( ${ $gv->FORM } == $$cv ) ? "pp_form_" : "pp_sub_";
$ppname .= ( $stashname eq "main" ) ? $gvname : "$stashname\::$gvname";
$ppname =~ s/::/__/g;
if ( $gvname eq "INIT" ) {
$ppname .= "_$initsub_index";
$initsub_index++;
}
warn sprintf( "saving op tree for CV 0x%x, root=0x%x\n",
$$cv, $$root )
if $debug{cv} and $debug{gv};
my $ppname = "";
if ($$gv) {
my $stashname = $gv->STASH->NAME;
my $gvname = $gv->NAME;
$fullname = $stashname.'::'.$gvname;
if ( $gvname ne "__ANON__" ) {
$ppname = ( ${ $gv->FORM } == $$cv ) ? "pp_form_" : "pp_sub_";
$ppname .= ( $stashname eq "main" ) ? $gvname : "$stashname\::$gvname";
$ppname =~ s/::/__/g;
if ( $gvname eq "INIT" ) {
$ppname .= "_$initsub_index";
$initsub_index++;
}
}
if ( !$ppname ) {
$ppname = "pp_anonsub_$anonsub_index";
$anonsub_index++;
}
$startfield = saveoptree( $ppname, $root, $cv->START, $padlist->ARRAY );
#warn sprintf( "done saving op tree for CV 0x%x, flags (%s), name %s, root=0x%x => start=%s\n",
# $$cv, $debug{flags}?$cv->flagspv:sprintf("0x%x",$cv->FLAGS), $ppname, $$root, $startfield )
# if $debug{cv};
# XXX missing cv_start for AUTOLOAD on 5.8
$startfield = objsym($root->next) unless $startfield; # 5.8 autoload has only root
$startfield = "0" unless $startfield;
if ($$padlist) {
# XXX readonly comppad names and symbols invalid
#local $B::C::pv_copy_on_grow = 1 if $B::C::ro_inc;
warn sprintf( "saving PADLIST 0x%x for CV 0x%x\n", $$padlist, $$cv )
if $debug{cv} and $debug{gv};
# XXX avlen 2
$padlistsym = $padlist->save($fullname.' :pad');
warn sprintf( "done saving PADLIST %s 0x%x for CV 0x%x\n",
$padlistsym, $$padlist, $$cv )
if $debug{cv} and $debug{gv};
# do not record a forward for the pad only
$init->add( "CvPADLIST($sym) = $padlistsym;" );
}
warn $fullname."\n" if $debug{sub};
}
else {
warn "&".$fullname." not found\n" if $verbose or $debug{sub};
warn "No definition for sub $fullname (unable to autoload), remove cv\n"
if $debug{cv};
$init->add( "/* $fullname not found */" ) if $verbose or $debug{sub};
# XXX empty CV should not be saved
$svsect->remove( $sv_ix );
$xpvcvsect->remove( $xpvcv_ix );
delsym( $cv );
return '0';
if ( !$ppname ) {
$ppname = "pp_anonsub_$anonsub_index";
$anonsub_index++;
}
$startfield = saveoptree( $ppname, $root, $cv->START, $padlist->ARRAY );
#warn sprintf( "done saving op tree for CV 0x%x, flags (%s), name %s, root=0x%x => start=%s\n",
# $$cv, $debug{flags}?$cv->flagspv:sprintf("0x%x",$cv->FLAGS), $ppname, $$root, $startfield )
# if $debug{cv};
# XXX missing cv_start for AUTOLOAD on 5.8
$startfield = objsym($root->next) unless $startfield; # 5.8 autoload has only root
$startfield = "0" unless $startfield;
if ($$padlist) {
# XXX readonly comppad names and symbols invalid
#local $B::C::pv_copy_on_grow = 1 if $B::C::ro_inc;
warn sprintf( "saving PADLIST 0x%x for CV 0x%x\n", $$padlist, $$cv )
if $debug{cv} and $debug{gv};
# XXX avlen 2
$padlistsym = $padlist->save($fullname.' :pad');
warn sprintf( "done saving PADLIST %s 0x%x for CV 0x%x\n",
$padlistsym, $$padlist, $$cv )
if $debug{cv} and $debug{gv};
# do not record a forward for the pad only
$init->add( "CvPADLIST($sym) = $padlistsym;" );
}
warn $fullname."\n" if $debug{sub};

# Now it is time to record the CV
if ($new_cv_fw) {
Expand Down

0 comments on commit 7883eda

Please sign in to comment.