This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
File/Spec.pm needs trailing newline
[perl5.git] / byterun.c
index d478a90..26cb5ac 100644 (file)
--- a/byterun.c
+++ b/byterun.c
@@ -1,5 +1,5 @@
 /*
- *      Copyright (c) 1996, 1997 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.
 
 #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) {
          case INSN_COMMENT:            /* 35 */
            {
-               comment arg;
-               BGET_comment(arg);
+               comment_t arg;
+               BGET_comment_t(arg);
                arg = arg;
                break;
            }
@@ -45,14 +55,14 @@ FILE *fp;
          case INSN_LDSV:               /* 1 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                sv = arg;
                break;
            }
          case INSN_LDOP:               /* 2 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                op = arg;
                break;
            }
@@ -147,7 +157,7 @@ FILE *fp;
          case INSN_XRV:                /* 17 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                SvRV(sv) = arg;
                break;
            }
@@ -194,7 +204,7 @@ FILE *fp;
          case INSN_XLV_TARG:           /* 24 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                LvTARG(sv) = arg;
                break;
            }
@@ -271,7 +281,7 @@ FILE *fp;
          case INSN_XIO_TOP_GV:         /* 36 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&IoTOP_GV(sv) = arg;
                break;
            }
@@ -285,7 +295,7 @@ FILE *fp;
          case INSN_XIO_FMT_GV:         /* 38 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&IoFMT_GV(sv) = arg;
                break;
            }
@@ -299,7 +309,7 @@ FILE *fp;
          case INSN_XIO_BOTTOM_GV:              /* 40 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&IoBOTTOM_GV(sv) = arg;
                break;
            }
@@ -327,35 +337,35 @@ FILE *fp;
          case INSN_XCV_STASH:          /* 44 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&CvSTASH(sv) = arg;
                break;
            }
          case INSN_XCV_START:          /* 45 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                CvSTART(sv) = arg;
                break;
            }
          case INSN_XCV_ROOT:           /* 46 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                CvROOT(sv) = arg;
                break;
            }
          case INSN_XCV_GV:             /* 47 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&CvGV(sv) = arg;
                break;
            }
          case INSN_XCV_FILEGV:         /* 48 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&CvFILEGV(sv) = arg;
                break;
            }
@@ -369,14 +379,14 @@ FILE *fp;
          case INSN_XCV_PADLIST:                /* 50 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&CvPADLIST(sv) = arg;
                break;
            }
          case INSN_XCV_OUTSIDE:                /* 51 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&CvOUTSIDE(sv) = arg;
                break;
            }
@@ -397,7 +407,7 @@ FILE *fp;
          case INSN_AV_PUSH:            /* 54 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                BSET_av_push(sv, arg);
                break;
            }
@@ -405,7 +415,7 @@ FILE *fp;
            {
                SSize_t arg;
                BGET_I32(arg);
-               AvFILL(sv) = arg;
+               AvFILLp(sv) = arg;
                break;
            }
          case INSN_XAV_MAX:            /* 56 */
@@ -439,7 +449,7 @@ FILE *fp;
          case INSN_HV_STORE:           /* 60 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                BSET_hv_store(sv, arg);
                break;
            }
@@ -453,7 +463,7 @@ FILE *fp;
          case INSN_MG_OBJ:             /* 62 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                SvMAGIC(sv)->mg_obj = arg;
                break;
            }
@@ -481,7 +491,7 @@ FILE *fp;
          case INSN_XMG_STASH:          /* 66 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&SvSTASH(sv) = arg;
                break;
            }
@@ -502,7 +512,7 @@ FILE *fp;
          case INSN_GP_SV:              /* 69 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                GvSV(sv) = arg;
                break;
            }
@@ -523,42 +533,42 @@ FILE *fp;
          case INSN_GP_AV:              /* 72 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&GvAV(sv) = arg;
                break;
            }
          case INSN_GP_HV:              /* 73 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&GvHV(sv) = arg;
                break;
            }
          case INSN_GP_CV:              /* 74 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&GvCV(sv) = arg;
                break;
            }
          case INSN_GP_FILEGV:          /* 75 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&GvFILEGV(sv) = arg;
                break;
            }
          case INSN_GP_IO:              /* 76 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&GvIOp(sv) = arg;
                break;
            }
          case INSN_GP_FORM:            /* 77 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&GvFORM(sv) = arg;
                break;
            }
@@ -579,7 +589,7 @@ FILE *fp;
          case INSN_GP_SHARE:           /* 80 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                BSET_gp_share(sv, arg);
                break;
            }
@@ -593,14 +603,14 @@ FILE *fp;
          case INSN_OP_NEXT:            /* 82 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                op->op_next = arg;
                break;
            }
          case INSN_OP_SIBLING:         /* 83 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                op->op_sibling = arg;
                break;
            }
@@ -649,35 +659,35 @@ FILE *fp;
          case INSN_OP_FIRST:           /* 90 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                cUNOP->op_first = arg;
                break;
            }
          case INSN_OP_LAST:            /* 91 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                cBINOP->op_last = arg;
                break;
            }
          case INSN_OP_OTHER:           /* 92 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                cLOGOP->op_other = arg;
                break;
            }
          case INSN_OP_TRUE:            /* 93 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                cCONDOP->op_true = arg;
                break;
            }
          case INSN_OP_FALSE:           /* 94 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                cCONDOP->op_false = arg;
                break;
            }
@@ -691,28 +701,28 @@ FILE *fp;
          case INSN_OP_PMREPLROOT:              /* 96 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                cPMOP->op_pmreplroot = arg;
                break;
            }
          case INSN_OP_PMREPLROOTGV:            /* 97 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&cPMOP->op_pmreplroot = arg;
                break;
            }
          case INSN_OP_PMREPLSTART:             /* 98 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                cPMOP->op_pmreplstart = arg;
                break;
            }
          case INSN_OP_PMNEXT:          /* 99 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                *(OP**)&cPMOP->op_pmnext = arg;
                break;
            }
@@ -723,143 +733,129 @@ FILE *fp;
                BSET_pregcomp(op, arg);
                break;
            }
-         case INSN_OP_PMSHORT:         /* 101 */
-           {
-               svindex arg;
-               BGET_objindex(arg);
-               cPMOP->op_pmshort = arg;
-               break;
-           }
-         case INSN_OP_PMFLAGS:         /* 102 */
+         case INSN_OP_PMFLAGS:         /* 101 */
            {
                U16 arg;
                BGET_U16(arg);
                cPMOP->op_pmflags = arg;
                break;
            }
-         case INSN_OP_PMPERMFLAGS:             /* 103 */
+         case INSN_OP_PMPERMFLAGS:             /* 102 */
            {
                U16 arg;
                BGET_U16(arg);
                cPMOP->op_pmpermflags = arg;
                break;
            }
-         case INSN_OP_PMSLEN:          /* 104 */
-           {
-               char arg;
-               BGET_U8(arg);
-               cPMOP->op_pmslen = arg;
-               break;
-           }
-         case INSN_OP_SV:              /* 105 */
+         case INSN_OP_SV:              /* 103 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                cSVOP->op_sv = arg;
                break;
            }
-         case INSN_OP_GV:              /* 106 */
+         case INSN_OP_GV:              /* 104 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&cGVOP->op_gv = arg;
                break;
            }
-         case INSN_OP_PV:              /* 107 */
+         case INSN_OP_PV:              /* 105 */
            {
                pvcontents arg;
                BGET_pvcontents(arg);
                cPVOP->op_pv = arg;
                break;
            }
-         case INSN_OP_PV_TR:           /* 108 */
+         case INSN_OP_PV_TR:           /* 106 */
            {
                op_tr_array arg;
                BGET_op_tr_array(arg);
                cPVOP->op_pv = arg;
                break;
            }
-         case INSN_OP_REDOOP:          /* 109 */
+         case INSN_OP_REDOOP:          /* 107 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                cLOOP->op_redoop = arg;
                break;
            }
-         case INSN_OP_NEXTOP:          /* 110 */
+         case INSN_OP_NEXTOP:          /* 108 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                cLOOP->op_nextop = arg;
                break;
            }
-         case INSN_OP_LASTOP:          /* 111 */
+         case INSN_OP_LASTOP:          /* 109 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                cLOOP->op_lastop = arg;
                break;
            }
-         case INSN_COP_LABEL:          /* 112 */
+         case INSN_COP_LABEL:          /* 110 */
            {
                pvcontents arg;
                BGET_pvcontents(arg);
                cCOP->cop_label = arg;
                break;
            }
-         case INSN_COP_STASH:          /* 113 */
+         case INSN_COP_STASH:          /* 111 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&cCOP->cop_stash = arg;
                break;
            }
-         case INSN_COP_FILEGV:         /* 114 */
+         case INSN_COP_FILEGV:         /* 112 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                *(SV**)&cCOP->cop_filegv = arg;
                break;
            }
-         case INSN_COP_SEQ:            /* 115 */
+         case INSN_COP_SEQ:            /* 113 */
            {
                U32 arg;
                BGET_U32(arg);
                cCOP->cop_seq = arg;
                break;
            }
-         case INSN_COP_ARYBASE:                /* 116 */
+         case INSN_COP_ARYBASE:                /* 114 */
            {
                I32 arg;
                BGET_I32(arg);
                cCOP->cop_arybase = arg;
                break;
            }
-         case INSN_COP_LINE:           /* 117 */
+         case INSN_COP_LINE:           /* 115 */
            {
                line_t arg;
                BGET_U16(arg);
                cCOP->cop_line = arg;
                break;
            }
-         case INSN_MAIN_START:         /* 118 */
+         case INSN_MAIN_START:         /* 116 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                main_start = arg;
                break;
            }
-         case INSN_MAIN_ROOT:          /* 119 */
+         case INSN_MAIN_ROOT:          /* 117 */
            {
                opindex arg;
-               BGET_objindex(arg);
+               BGET_opindex(arg);
                main_root = arg;
                break;
            }
-         case INSN_CURPAD:             /* 120 */
+         case INSN_CURPAD:             /* 118 */
            {
                svindex arg;
-               BGET_objindex(arg);
+               BGET_svindex(arg);
                BSET_curpad(curpad, arg);
                break;
            }