Allow escaping %m as %%m in Sys::Syslog format strings
[p5sagit/p5-mst-13.2.git] / bytecode.pl
index 1f30d9b..d471763 100644 (file)
@@ -4,8 +4,8 @@ BEGIN {
 }
 use strict;
 my %alias_to = (
-    U32 => [qw(PADOFFSET STRLEN line_t)],
-    I32 => [qw(SSize_t long)],
+    U32 => [qw(line_t)],
+    PADOFFSET => [qw(STRLEN SSize_t)],
     U16 => [qw(OPCODE short)],
     U8  => [qw(char)],
 );
@@ -43,10 +43,11 @@ safer_unlink "ext/ByteLoader/byterun.c", "ext/ByteLoader/byterun.h", "ext/B/B/As
 # Start with boilerplate for Asmdata.pm
 #
 open(ASMDATA_PM, ">ext/B/B/Asmdata.pm") or die "ext/B/B/Asmdata.pm: $!";
+binmode ASMDATA_PM;
 print ASMDATA_PM $perl_header, <<'EOT';
 package B::Asmdata;
 
-our $VERSION = '1.00';
+our $VERSION = '1.01';
 
 use Exporter;
 @ISA = qw(Exporter);
@@ -67,6 +68,7 @@ EOT
 # Boilerplate for byterun.c
 #
 open(BYTERUN_C, ">ext/ByteLoader/byterun.c") or die "ext/ByteLoader/byterun.c: $!";
+binmode BYTERUN_C;
 print BYTERUN_C $c_header, <<'EOT';
 
 #define PERL_NO_GET_CONTEXT
@@ -143,6 +145,10 @@ while (<DATA>) {
        next;
     }
     ($insn, $lvalue, $argtype, $flags) = split;
+    my $rvalcast = '';
+    if ($argtype =~ m:(.+)/(.+):) {
+       ($rvalcast, $argtype) = ("($1)", $2);
+    }
     $insn_name[$insn_num] = $insn;
     $fundtype = $alias_from{$argtype} || $argtype;
 
@@ -162,7 +168,7 @@ while (<DATA>) {
        print BYTERUN_C "\t\tBSET_OBJ_STORE($lvalue$optarg);\n";
     }
     elsif ($optarg && $lvalue ne "none") {
-       print BYTERUN_C "\t\t$lvalue = arg;\n";
+       print BYTERUN_C "\t\t$lvalue = ${rvalcast}arg;\n";
     }
     print BYTERUN_C "\t\tbreak;\n\t    }\n";
 
@@ -194,6 +200,7 @@ EOT
 # Write the instruction and optype enum constants into byterun.h
 #
 open(BYTERUN_H, ">ext/ByteLoader/byterun.h") or die "ext/ByteLoader/byterun.h: $!";
+binmode BYTERUN_H;
 print BYTERUN_H $c_header, <<'EOT';
 struct byteloader_fdata {
     SV *datasv;
@@ -337,6 +344,8 @@ nop         none                    none
 # ret so that \0-terminated strings can be read properly as bytecode.
 %number 0
 #
+# The argtype is either a single type or "rightvaluecast/argtype".
+#
 #opcode                lvalue                                  argtype         flags   
 #
 ret            none                                    none            x
@@ -436,7 +445,8 @@ op_sibling  PL_op->op_sibling                       opindex
 op_ppaddr      PL_op->op_ppaddr                        strconst        x
 op_targ                PL_op->op_targ                          PADOFFSET
 op_type                PL_op                                   OPCODE          x
-op_seq         PL_op->op_seq                           U16
+op_opt         PL_op->op_opt                           U8
+op_static      PL_op->op_static                        U8
 op_flags       PL_op->op_flags                         U8
 op_private     PL_op->op_private                       U8
 op_first       cUNOP->op_first                         opindex
@@ -446,8 +456,8 @@ op_pmreplroot       cPMOP->op_pmreplroot                    opindex
 op_pmreplstart cPMOP->op_pmreplstart                   opindex
 op_pmnext      *(OP**)&cPMOP->op_pmnext                opindex
 #ifdef USE_ITHREADS
-op_pmstashpv   cPMOP->op_pmstashpv                     pvindex
-op_pmreplrootpo        (PADOFFSET)cPMOP->op_pmreplroot         PADOFFSET
+op_pmstashpv   cPMOP                                   pvindex         x
+op_pmreplrootpo        cPMOP->op_pmreplroot                    OP*/PADOFFSET
 #else
 op_pmstash     *(SV**)&cPMOP->op_pmstash               svindex
 op_pmreplrootgv        *(SV**)&cPMOP->op_pmreplroot            svindex
@@ -486,7 +496,7 @@ push_end    PL_endav                                svindex         x
 curstash       *(SV**)&PL_curstash                     svindex
 defstash       *(SV**)&PL_defstash                     svindex
 data           none                                    U8              x
-incav          *(SV**)&PL_incgv                        svindex
+incav          *(SV**)&GvAV(PL_incgv)                  svindex
 load_glob      none                                    svindex         x
 #ifdef USE_ITHREADS
 regex_padav    *(SV**)&PL_regex_padav                  svindex