This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
[perl5.git] / ext / ByteLoader / bytecode.h
index bd62b28..c8da60d 100644 (file)
@@ -20,6 +20,10 @@ typedef char *pvindex;
        BGET_FREAD(&arg, sizeof(U32), 1)
 #define BGET_UV(arg)   \
        BGET_FREAD(&arg, sizeof(UV), 1)
+#define BGET_PADOFFSET(arg)    \
+       BGET_FREAD(&arg, sizeof(PADOFFSET), 1)
+#define BGET_long(arg)         \
+       BGET_FREAD(&arg, sizeof(long), 1)
 
 #define BGET_I32(arg)  BGET_U32(arg)
 #define BGET_IV(arg)   BGET_UV(arg)
@@ -27,8 +31,8 @@ typedef char *pvindex;
 #define BGET_PV(arg)   STMT_START {                                    \
        BGET_U32(arg);                                                  \
        if (arg) {                                                      \
-           New(666, bstate->bs_pv.xpv_pv, arg, char);                  \
-           bl_read(bstate->bs_fdata, (void*)bstate->bs_pv.xpv_pv, arg, 1);\
+           Newx(bstate->bs_pv.xpv_pv, arg, char);                      \
+           bl_read(bstate->bs_fdata, bstate->bs_pv.xpv_pv, arg, 1);    \
            bstate->bs_pv.xpv_len = arg;                                \
            bstate->bs_pv.xpv_cur = arg - 1;                            \
        } else {                                                        \
@@ -59,7 +63,7 @@ typedef char *pvindex;
 #define BGET_op_tr_array(arg) do {                     \
        unsigned short *ary, len;                       \
        BGET_U16(len);                                  \
-       New(666, ary, len, unsigned short);             \
+       Newx(ary, len, unsigned short);         \
        BGET_FREAD(ary, sizeof(unsigned short), len);   \
        arg = (char *) ary;                             \
     } while (0)
@@ -122,12 +126,19 @@ typedef char *pvindex;
 #define BSET_mg_namex(mg, arg)                 \
        (mg->mg_ptr = (char*)SvREFCNT_inc((SV*)arg),    \
         mg->mg_len = HEf_SVKEY)
+#define BSET_xmg_stash(sv, arg) *(SV**)&(((XPVMG*)SvANY(sv))->xmg_stash) = (arg)
 #define BSET_sv_upgrade(sv, arg)       (void)SvUPGRADE(sv, arg)
+#define BSET_xrv(sv, arg) SvRV_set(sv, arg)
 #define BSET_xpv(sv)   do {    \
        SvPV_set(sv, bstate->bs_pv.xpv_pv);     \
        SvCUR_set(sv, bstate->bs_pv.xpv_cur);   \
        SvLEN_set(sv, bstate->bs_pv.xpv_len);   \
     } while (0)
+#define BSET_xpv_cur(sv, arg) SvCUR_set(sv, arg)
+#define BSET_xpv_len(sv, arg) SvLEN_set(sv, arg)
+#define BSET_xiv(sv, arg) SvIV_set(sv, arg)
+#define BSET_xnv(sv, arg) SvNV_set(sv, arg)
+
 #define BSET_av_extend(sv, arg)        av_extend((AV*)sv, arg)
 
 #define BSET_av_push(sv, arg)  av_push((AV*)sv, arg)
@@ -171,25 +182,30 @@ typedef char *pvindex;
 
 
 #define BSET_newsv(sv, arg)                            \
-       STMT_START {                                    \
-           sv = (arg == SVt_PVAV ? (SV*)newAV() :      \
-                 arg == SVt_PVHV ? (SV*)newHV() :      \
-                 NEWSV(666,0));                        \
-           SvUPGRADE(sv, arg);                         \
-       } STMT_END
+           switch(arg) {                               \
+           case SVt_PVAV:                              \
+               sv = (SV*)newAV();                      \
+               break;                                  \
+           case SVt_PVHV:                              \
+               sv = (SV*)newHV();                      \
+               break;                                  \
+           default:                                    \
+               sv = NEWSV(0,0);                        \
+               SvUPGRADE(sv, (arg));                   \
+           }
 #define BSET_newsvx(sv, arg) STMT_START {              \
            BSET_newsv(sv, arg &  SVTYPEMASK);          \
            SvFLAGS(sv) = arg;                          \
            BSET_OBJ_STOREX(sv);                        \
        } STMT_END
-#define BSET_newop(o, arg)                             \
-       ((o = (OP*)safemalloc(arg)), memzero((char*)o,arg))
+
+#define BSET_newop(o, arg)     NewOpSz(666, o, arg)
 #define BSET_newopx(o, arg) STMT_START {       \
        register int sz = arg & 0x7f;           \
-       register OP* new = (OP*) safemalloc(sz);\
-       memzero(new, sz);                       \
-       /* new->op_next = o; XXX */             \
-       o = new;                                \
+       register OP* newop;                     \
+       BSET_newop(newop, sz);                  \
+       /* newop->op_next = o; XXX */           \
+       o = newop;                              \
        arg >>=7;                               \
        BSET_op_type(o, arg);                   \
        BSET_OBJ_STOREX(o);                     \
@@ -206,6 +222,8 @@ typedef char *pvindex;
        return 0;                               \
     } STMT_END
 
+#define BSET_op_pmstashpv(op, arg)     PmopSTASHPV_set(op, arg)
+
 /* 
  * stolen from toke.c: better if that was a function.
  * in toke.c there are also #ifdefs for dosish systems and i/o layers
@@ -329,6 +347,8 @@ typedef char *pvindex;
        mg_set(*hv_store(GvHV(gv_fetchpv("SIG", TRUE, SVt_PVHV)),       \
                name, strlen(name), cv, 0))
 
+#define BSET_xhv_name(hv, name)        hv_name_set((HV*)hv, name, strlen(name), 0)
+
 /* NOTE: the bytecode header only sanity-checks the bytecode. If a script cares about
  * what version of Perl it's being called under, it should do a 'use 5.006_001' or
  * equivalent. However, since the header includes checks requiring an exact match in
@@ -372,8 +392,4 @@ typedef char *pvindex;
            if (sz != PTRSIZE) {                                \
                HEADER_FAIL("different PTRSIZE");               \
            }                                                   \
-           BGET_strconst(str); /* byteorder */                 \
-           if (strNE(str, STRINGIFY(BYTEORDER))) {             \
-               HEADER_FAIL("different byteorder");     \
-           }                                                   \
        } STMT_END