X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=bytecode.pl;h=38ae8092a9a53a307712ccc68a7cd085d19afff6;hb=1bb0a50fd869bf3d7f152d29ec8c8119703266a1;hp=0e28020e99a6356c0e455e2eeb398b4a5fdf653b;hpb=e3751d82ab424ea356f7b822ac173dabf670d6d2;p=p5sagit%2Fp5-mst-13.2.git diff --git a/bytecode.pl b/bytecode.pl index 0e28020..38ae809 100644 --- a/bytecode.pl +++ b/bytecode.pl @@ -1,5 +1,6 @@ BEGIN { push @INC, './lib'; + require 'regen_lib.pl'; } use strict; my %alias_to = ( @@ -36,7 +37,7 @@ EOT my $perl_header; ($perl_header = $c_header) =~ s{[/ ]?\*/?}{#}g; -unlink "ext/ByteLoader/byterun.c", "ext/ByteLoader/byterun.h", "ext/B/B/Asmdata.pm"; +safer_unlink "ext/ByteLoader/byterun.c", "ext/ByteLoader/byterun.h", "ext/B/B/Asmdata.pm"; # # Start with boilerplate for Asmdata.pm @@ -44,6 +45,9 @@ unlink "ext/ByteLoader/byterun.c", "ext/ByteLoader/byterun.h", "ext/B/B/Asmdata. open(ASMDATA_PM, ">ext/B/B/Asmdata.pm") or die "ext/B/B/Asmdata.pm: $!"; print ASMDATA_PM $perl_header, <<'EOT'; package B::Asmdata; + +our $VERSION = '1.00'; + use Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw(%insn_data @insn_name @optype @specialsv_name); @@ -254,11 +258,53 @@ B::Asmdata - Autogenerated data about Perl ops, used to generate bytecode =head1 SYNOPSIS - use Asmdata; + use B::Asmdata qw(%insn_data @insn_name @optype @specialsv_name); =head1 DESCRIPTION -See F. +Provides information about Perl ops in order to generate bytecode via +a bunch of exported variables. Its mostly used by B::Assembler and +B::Disassembler. + +=over 4 + +=item %insn_data + + my($bytecode_num, $put_sub, $get_meth) = @$insn_data{$op_name}; + +For a given $op_name (for example, 'cop_label', 'sv_flags', etc...) +you get an array ref containing the bytecode number of the op, a +reference to the subroutine used to 'PUT', and the name of the method +used to 'GET'. + +=for _private +Add more detail about what $put_sub and $get_meth are and how to use them. + +=item @insn_name + + my $op_name = $insn_name[$bytecode_num]; + +A simple mapping of the bytecode number to the name of the op. +Suitable for using with %insn_data like so: + + my $op_info = $insn_data{$insn_name[$bytecode_num]}; + +=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 refered 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 AUTHOR @@ -267,6 +313,11 @@ Malcolm Beattie, C =cut EOT + +close ASMDATA_PM or die "Error closing ASMDATA_PM: $!"; +close BYTERUN_H or die "Error closing BYTERUN_H: $!"; +close BYTERUN_C or die "Error closing BYTERUN_C: $!"; + __END__ # First set instruction ord("#") to read comment to end-of-line (sneaky) %number 35 @@ -293,7 +344,7 @@ newopn PL_op U8 x newpv none PV pv_cur bstate->bs_pv.xpv_cur STRLEN pv_free bstate->bs_pv none x -sv_upgrade bstate->bs_sv char x +sv_upgrade bstate->bs_sv U8 x sv_refcnt SvREFCNT(bstate->bs_sv) U32 sv_refcnt_add SvREFCNT(bstate->bs_sv) I32 x sv_flags SvFLAGS(bstate->bs_sv) U32 @@ -309,11 +360,11 @@ xlv_type LvTYPE(bstate->bs_sv) char xbm_useful BmUSEFUL(bstate->bs_sv) I32 xbm_previous BmPREVIOUS(bstate->bs_sv) U16 xbm_rare BmRARE(bstate->bs_sv) U8 -xfm_lines FmLINES(bstate->bs_sv) I32 -xio_lines IoLINES(bstate->bs_sv) long -xio_page IoPAGE(bstate->bs_sv) long -xio_page_len IoPAGE_LEN(bstate->bs_sv) long -xio_lines_left IoLINES_LEFT(bstate->bs_sv) long +xfm_lines FmLINES(bstate->bs_sv) IV +xio_lines IoLINES(bstate->bs_sv) IV +xio_page IoPAGE(bstate->bs_sv) IV +xio_page_len IoPAGE_LEN(bstate->bs_sv) IV +xio_lines_left IoLINES_LEFT(bstate->bs_sv) IV xio_top_name IoTOP_NAME(bstate->bs_sv) pvcontents xio_top_gv *(SV**)&IoTOP_GV(bstate->bs_sv) svindex xio_fmt_name IoFMT_NAME(bstate->bs_sv) pvcontents @@ -331,6 +382,7 @@ xcv_file CvFILE(bstate->bs_sv) pvindex xcv_depth CvDEPTH(bstate->bs_sv) long xcv_padlist *(SV**)&CvPADLIST(bstate->bs_sv) svindex xcv_outside *(SV**)&CvOUTSIDE(bstate->bs_sv) svindex +xcv_outside_seq CvOUTSIDE_SEQ(bstate->bs_sv) U32 xcv_flags CvFLAGS(bstate->bs_sv) U16 av_extend bstate->bs_sv SSize_t x av_push bstate->bs_sv svindex x