hand apply whitespace mutiliated patch
[p5sagit/p5-mst-13.2.git] / bytecode.pl
index 0f79e65..91d6bf1 100644 (file)
@@ -4,7 +4,6 @@ my %alias_to = (
     I32 => [qw(SSize_t long)],
     U16 => [qw(OPCODE line_t short)],
     U8 => [qw(char)],
-    objindex => [qw(svindex opindex)]          
 );
 
 my @optype= qw(OP UNOP BINOP LOGOP CONDOP LISTOP PMOP SVOP GVOP PVOP LOOP COP);
@@ -20,7 +19,7 @@ while (($from, $tos) = each %alias_to) {
 
 my $c_header = <<'EOT';
 /*
- *      Copyright (c) 1996 Malcolm Beattie
+ *      Copyright (c) 1996-1998 Malcolm Beattie
  *
  *      You may distribute under the terms of either the GNU General Public
  *      License or the Artistic License, as specified in the README file.
@@ -34,20 +33,12 @@ EOT
 my $perl_header;
 ($perl_header = $c_header) =~ s{[/ ]?\*/?}{#}g;
 
-if (-f "byterun.c") {
-    rename("byterun.c", "byterun.c.old");
-}
-if (-f "byterun.h") {
-    rename("byterun.h", "byterun.h.old");
-}
-if (-f "Asmdata.pm") {
-    rename("Asmdata.pm", "Asmdata.pm.old");
-}
+unlink "byterun.c", "byterun.h", "ext/B/B/Asmdata.pm";
 
 #
 # Start with boilerplate for Asmdata.pm
 #
-open(ASMDATA_PM, ">Asmdata.pm") or die "Asmdata.pm: $!";
+open(ASMDATA_PM, ">ext/B/B/Asmdata.pm") or die "ext/B/B/Asmdata.pm: $!";
 print ASMDATA_PM $perl_header, <<'EOT';
 package B::Asmdata;
 use Exporter;
@@ -73,19 +64,30 @@ print BYTERUN_C $c_header, <<'EOT';
 
 #include "EXTERN.h"
 #include "perl.h"
-#include "bytecode.h"
-#include "byterun.h"
+
+void *
+bset_obj_store(void *obj, I32 ix)
+{
+    if (ix > obj_list_fill) {
+       if (obj_list_fill == -1)
+           New(666, obj_list, ix + 1, void*);
+       else
+           Renew(obj_list, ix + 1, void*);
+       obj_list_fill = ix;
+    }
+    obj_list[ix] = obj;
+    return obj;
+}
 
 #ifdef INDIRECT_BGET_MACROS
-void byterun(bs)
-struct bytestream bs;
+void byterun(struct bytestream bs)
 #else
-void byterun(fp)
-FILE *fp;
+void byterun(PerlIO *fp)
 #endif /* INDIRECT_BGET_MACROS */
 {
+    dTHR;
     int insn;
-    while ((insn = FGETC()) != EOF) {
+    while ((insn = BGET_FGETC()) != EOF) {
        switch (insn) {
 EOT
 
@@ -162,12 +164,10 @@ struct bytestream {
     int (*fread)(char *, size_t, size_t, void*);
     void (*freadpv)(U32, void*);
 };
-void freadpv _((U32, void *));
-void byterun _((struct bytestream));
-#else
-void byterun _((FILE *));
 #endif /* INDIRECT_BGET_MACROS */
 
+void *bset_obj_store _((void *, I32));
+
 enum {
 EOT
 
@@ -211,14 +211,14 @@ print BYTERUN_H <<'EOT';
 
 EOT
 
-printf BYTERUN_H <<'EOT', scalar(@specialsv);
-EXT SV * specialsv_list[%d]
-#ifdef DOINIT
+print BYTERUN_H <<'EOT';
+#define INIT_SPECIALSV_LIST STMT_START { \
 EOT
-print BYTERUN_H "= { ", join(", ", @specialsv), " }\n";
+for ($i = 0; $i < @specialsv; $i++) {
+    print BYTERUN_H "\tspecialsv_list[$i] = $specialsv[$i]; \\\n";
+}
 print BYTERUN_H <<'EOT';
-#endif /* DOINIT */
-;
+    } STMT_END
 EOT
 
 #
@@ -239,7 +239,7 @@ EOT
 __END__
 # First set instruction ord("#") to read comment to end-of-line (sneaky)
 %number 35
-comment                arg                     comment
+comment                arg                     comment_t
 # Then make ord("\n") into a no-op
 %number 10
 nop            none                    none
@@ -302,7 +302,7 @@ xcv_outside *(SV**)&CvOUTSIDE(sv)   svindex
 xcv_flags      CvFLAGS(sv)             U8
 av_extend      sv                      SSize_t         x
 av_push                sv                      svindex         x
-xav_fill       AvFILL(sv)              SSize_t
+xav_fill       AvFILLp(sv)             SSize_t
 xav_max                AvMAX(sv)               SSize_t
 xav_flags      AvFLAGS(sv)             U8
 xhv_riter      HvRITER(sv)             I32
@@ -348,10 +348,8 @@ op_pmreplrootgv    *(SV**)&cPMOP->op_pmreplroot    svindex
 op_pmreplstart cPMOP->op_pmreplstart   opindex
 op_pmnext      *(OP**)&cPMOP->op_pmnext        opindex
 pregcomp       op                      pvcontents      x
-op_pmshort     cPMOP->op_pmshort       svindex
 op_pmflags     cPMOP->op_pmflags       U16
 op_pmpermflags cPMOP->op_pmpermflags   U16
-op_pmslen      cPMOP->op_pmslen        char
 op_sv          cSVOP->op_sv            svindex
 op_gv          *(SV**)&cGVOP->op_gv    svindex
 op_pv          cPVOP->op_pv            pvcontents