sub save_unused_subs
{
no strict qw(refs);
+ &descend_marked_unused;
warn "Prescan\n";
walkpackages(\%{"main::"}, sub { should_save($_[0]); return 1 });
warn "Saving methods\n";
"av_store(CvPADLIST(PL_main_cv),1,SvREFCNT_inc($curpad_sym));");
}
+sub descend_marked_unused {
+ foreach my $pack (keys %unused_sub_packages)
+ {
+ mark_package($pack);
+ }
+}
+
sub save_main {
warn "Starting compile\n";
- foreach my $pack (keys %unused_sub_packages)
- {
- mark_package($pack);
- }
warn "Walking tree\n";
walkoptree(main_root, "save");
warn "done main optree, walking symtable for extras\n" if $debug_cv;
}
}
-my @unused_sub_packages; # list of packages (given by -u options) to search
- # explicitly and save every sub we find there, even
- # if apparently unused (could be only referenced from
- # an eval "" or from a $SIG{FOO} = "bar").
my ($module_name);
my ($debug_op, $debug_stack, $debug_cxstack, $debug_pad, $debug_runtime,
sub top_double { @stack ? $stack[-1]->as_double : "TOPn" }
sub top_numeric { @stack ? $stack[-1]->as_numeric : "TOPn" }
sub top_sv { @stack ? $stack[-1]->as_sv : "TOPs" }
-sub top_bool { @stack ? $stack[-1]->as_numeric : "SvTRUE(TOPs)" }
+sub top_bool { @stack ? $stack[-1]->as_bool : "SvTRUE(TOPs)" }
sub pop_int { @stack ? (pop @stack)->as_int : "POPi" }
sub pop_double { @stack ? (pop @stack)->as_double : "POPn" }
sub pop_sv { @stack ? (pop @stack)->as_sv : "POPs" }
sub pop_bool {
if (@stack) {
- return ((pop @stack)->as_numeric);
+ return ((pop @stack)->as_bool);
} else {
# Careful: POPs has an auto-decrement and SvTRUE evaluates
# its argument more than once.
write_back_lexicals(REGISTER|TEMPORARY);
write_back_stack();
doop($op);
- runtime("PUTBACK;", "return (PL_op)?PL_op->op_next:0;");
+ runtime("PUTBACK;", "return PL_op;");
$know_op = 0;
return $op->next;
}
$need_freetmps = 0;
}
if (!$$op) {
- runtime("PUTBACK;","return (PL_op)?PL_op->op_next:0;");
+ runtime("PUTBACK;","return PL_op;");
} elsif ($done{$$op}) {
runtime(sprintf("goto %s;", label($op)));
}
} elsif ($opt eq "m") {
$arg ||= shift @options;
$module = $arg;
- push(@unused_sub_packages, $arg);
+ mark_unused($arg,undef);
} elsif ($opt eq "p") {
$arg ||= shift @options;
$patchlevel = $arg;