From: Nicholas Clark Date: Mon, 7 May 2007 14:53:05 +0000 (+0000) Subject: Given that @optype and @specialsv_name are hard coded tables, it seems X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=baccf54f1213c0da51c9cff1078e4351fc442f70;p=p5sagit%2Fp5-mst-13.2.git Given that @optype and @specialsv_name are hard coded tables, it seems more logical for them to be in B.pm, rather than in the "boilerplate" for the machine generated B/Asmdata.pm p4raw-id: //depot/perl@31164 --- diff --git a/bytecode.pl b/bytecode.pl index 49ad8f1..6d09f8e 100644 --- a/bytecode.pl +++ b/bytecode.pl @@ -10,13 +10,6 @@ my %alias_to = ( U8 => [qw(char)], ); -my @optype= qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP LOOP COP); - -# Nullsv *must* come first in the following so that the condition -# ($$sv == 0) can continue to be used to test (sv == Nullsv). -my @specialsv = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no - (SV*)pWARN_ALL (SV*)pWARN_NONE (SV*)pWARN_STD); - my (%alias_from, $from, $tos); while (($from, $tos) = each %alias_to) { map { $alias_from{$_} = $from } @$tos; @@ -49,25 +42,22 @@ binmode ASMDATA_PM; print ASMDATA_PM $perl_header, <<'EOT'; package B::Asmdata; -our $VERSION = '1.01'; +our $VERSION = '1.02'; use Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw(%insn_data @insn_name @optype @specialsv_name); -our(%insn_data, @insn_name, @optype, @specialsv_name); +our(%insn_data, @insn_name); +use B qw(@optype @specialsv_name); EOT print ASMDATA_PM <<"EOT"; -\@optype = qw(@optype); -\@specialsv_name = qw(@specialsv); # XXX insn_data is initialised this way because with a large # %insn_data = (foo => [...], bar => [...], ...) initialiser # I get a hard-to-track-down stack underflow and segfault. EOT -my $size = @specialsv; - my (@insn_name, $insn_num, $insn, $lvalue, $argtype, $flags, $fundtype); while () { diff --git a/ext/B/B.pm b/ext/B/B.pm index 5336169..13ff5b3 100644 --- a/ext/B/B.pm +++ b/ext/B/B.pm @@ -22,7 +22,7 @@ require Exporter; walkoptree_slow walkoptree walkoptree_exec walksymtable parents comppadlist sv_undef compile_stats timing_info begin_av init_av check_av end_av regex_padav dowarn defstash - curstash warnhook diehook inc_gv + curstash warnhook diehook inc_gv @optype @specialsv_name ); push @EXPORT_OK, qw(unitcheck_av) if $] > 5.009; @@ -61,6 +61,13 @@ use strict; @B::SPECIAL::ISA = 'B::OBJECT'; +@B::optype = qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP LOOP COP); +# bytecode.pl contained the following comment: +# Nullsv *must* come first in the following so that the condition +# ($$sv == 0) can continue to be used to test (sv == Nullsv). +@B::specialsv_name = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no + (SV*)pWARN_ALL (SV*)pWARN_NONE (SV*)pWARN_STD); + { # Stop "-w" from complaining about the lack of a real B::OBJECT class package B::OBJECT; @@ -520,7 +527,26 @@ per-thread threadsv variables. =back +=head2 Exported utility variabiles + +=over 4 + +=item @optype + + my $op_type = $optype[$op_type_num]; +A simple mapping of the op type number to its type (like 'COP' or 'BINOP'). + +=item @specialsv_name + + my $sv_name = $specialsv_name[$sv_index]; + +Certain SV types are considered 'special'. They're represented by +B::SPECIAL and are referred to by a number from the specialsv_list. +This array maps that number back to the name of the SV (like 'Nullsv' +or '&PL_sv_undef'). + +=back =head1 OVERVIEW OF CLASSES diff --git a/ext/B/B/Asmdata.pm b/ext/B/B/Asmdata.pm index b43f7bb..bbea25f 100644 --- a/ext/B/B/Asmdata.pm +++ b/ext/B/B/Asmdata.pm @@ -11,15 +11,14 @@ # package B::Asmdata; -our $VERSION = '1.01'; +our $VERSION = '1.02'; use Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw(%insn_data @insn_name @optype @specialsv_name); -our(%insn_data, @insn_name, @optype, @specialsv_name); +our(%insn_data, @insn_name); -@optype = qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP LOOP COP); -@specialsv_name = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no (SV*)pWARN_ALL (SV*)pWARN_NONE (SV*)pWARN_STD); +use B qw(@optype @specialsv_name); # XXX insn_data is initialised this way because with a large # %insn_data = (foo => [...], bar => [...], ...) initialiser diff --git a/ext/B/B/Debug.pm b/ext/B/B/Debug.pm index db5d0f0..0e1d224 100644 --- a/ext/B/B/Debug.pm +++ b/ext/B/B/Debug.pm @@ -1,11 +1,10 @@ package B::Debug; -our $VERSION = '1.03'; +our $VERSION = '1.04'; use strict; use B qw(peekop class walkoptree walkoptree_exec - main_start main_root cstring sv_undef); -use B::Asmdata qw(@specialsv_name); + main_start main_root cstring sv_undef @specialsv_name); my %done_gv; diff --git a/ext/B/B/Terse.pm b/ext/B/B/Terse.pm index da6e48a..562c58a 100644 --- a/ext/B/B/Terse.pm +++ b/ext/B/B/Terse.pm @@ -1,10 +1,9 @@ package B::Terse; -our $VERSION = '1.04'; +our $VERSION = '1.05'; use strict; -use B qw(class); -use B::Asmdata qw(@specialsv_name); +use B qw(class @specialsv_name); use B::Concise qw(concise_subref set_style_standard); use Carp;