1 typedef char *pvcontents;
2 typedef char *strconst;
4 typedef char *op_tr_array;
10 #define BGET_FREAD(argp, len, nelem) \
11 bs.pfread((char*)(argp),(len),(nelem),bs.data)
12 #define BGET_FGETC() bs.pfgetc(bs.data)
14 #define BGET_U32(arg) \
15 BGET_FREAD(&arg, sizeof(U32), 1); arg = PerlSock_ntohl((U32)arg)
16 #define BGET_I32(arg) \
17 BGET_FREAD(&arg, sizeof(I32), 1); arg = (I32)PerlSock_ntohl((U32)arg)
18 #define BGET_U16(arg) \
19 BGET_FREAD(&arg, sizeof(U16), 1); arg = PerlSock_ntohs((U16)arg)
20 #define BGET_U8(arg) arg = BGET_FGETC()
22 #define BGET_PV(arg) STMT_START { \
25 bs.pfreadpv(arg, bs.data, &bytecode_pv); \
27 bytecode_pv.xpv_pv = 0; \
28 bytecode_pv.xpv_len = 0; \
29 bytecode_pv.xpv_cur = 0; \
33 #define BGET_comment_t(arg) \
34 do { arg = BGET_FGETC(); } while (arg != '\n' && arg != EOF)
37 * In the following, sizeof(IV)*4 is just a way of encoding 32 on 64-bit-IV
38 * machines such that 32-bit machine compilers don't whine about the shift
39 * count being too high even though the code is never reached there.
41 #define BGET_IV64(arg) STMT_START { \
45 if (sizeof(IV) == 8) \
46 arg = ((IV)hi << (sizeof(IV)*4) | (IV)lo); \
47 else if (((I32)hi == -1 && (I32)lo < 0) \
48 || ((I32)hi == 0 && (I32)lo >= 0)) { \
52 bytecode_iv_overflows++; \
57 #define BGET_op_tr_array(arg) do { \
58 unsigned short *ary; \
60 New(666, ary, 256, unsigned short); \
61 BGET_FREAD(ary, 256, 2); \
62 for (i = 0; i < 256; i++) \
63 ary[i] = PerlSock_ntohs(ary[i]); \
67 #define BGET_pvcontents(arg) arg = bytecode_pv.xpv_pv
68 #define BGET_strconst(arg) STMT_START { \
69 for (arg = PL_tokenbuf; (*arg = BGET_FGETC()); arg++) /* nothing */; \
73 #define BGET_NV(arg) STMT_START { \
79 #define BGET_objindex(arg, type) STMT_START { \
82 arg = (type)bytecode_obj_list[ix]; \
84 #define BGET_svindex(arg) BGET_objindex(arg, svindex)
85 #define BGET_opindex(arg) BGET_objindex(arg, opindex)
87 #define BSET_ldspecsv(sv, arg) sv = specialsv_list[arg]
89 #define BSET_sv_refcnt_add(svrefcnt, arg) svrefcnt += arg
90 #define BSET_gp_refcnt_add(gprefcnt, arg) gprefcnt += arg
91 #define BSET_gp_share(sv, arg) STMT_START { \
93 GvGP(sv) = GvGP(arg); \
96 #define BSET_gv_fetchpv(sv, arg) sv = (SV*)gv_fetchpv(arg, TRUE, SVt_PV)
97 #define BSET_gv_stashpv(sv, arg) sv = (SV*)gv_stashpv(arg, TRUE)
98 #define BSET_sv_magic(sv, arg) sv_magic(sv, Nullsv, arg, 0, 0)
99 #define BSET_mg_pv(mg, arg) mg->mg_ptr = arg; mg->mg_len = bytecode_pv.xpv_cur
100 #define BSET_sv_upgrade(sv, arg) (void)SvUPGRADE(sv, arg)
101 #define BSET_xpv(sv) do { \
102 SvPV_set(sv, bytecode_pv.xpv_pv); \
103 SvCUR_set(sv, bytecode_pv.xpv_cur); \
104 SvLEN_set(sv, bytecode_pv.xpv_len); \
106 #define BSET_av_extend(sv, arg) av_extend((AV*)sv, arg)
108 #define BSET_av_push(sv, arg) av_push((AV*)sv, arg)
109 #define BSET_hv_store(sv, arg) \
110 hv_store((HV*)sv, bytecode_pv.xpv_pv, bytecode_pv.xpv_cur, arg, 0)
111 #define BSET_pv_free(pv) Safefree(pv.xpv_pv)
112 #define BSET_pregcomp(o, arg) \
113 ((PMOP*)o)->op_pmregexp = arg ? \
114 CALLREGCOMP(aTHX_ arg, arg + bytecode_pv.xpv_cur, ((PMOP*)o)) : 0
115 #define BSET_newsv(sv, arg) sv = NEWSV(666,0); SvUPGRADE(sv, arg)
116 #define BSET_newop(o, arg) o = (OP*)safemalloc(optype_size[arg])
117 #define BSET_newopn(o, arg) STMT_START { \
119 BSET_newop(o, arg); \
120 oldop->op_next = o; \
123 #define BSET_ret(foo) return
126 * Kludge special-case workaround for OP_MAPSTART
127 * which needs the ppaddr for OP_GREPSTART. Blech.
129 #define BSET_op_type(o, arg) STMT_START { \
131 if (arg == OP_MAPSTART) \
132 arg = OP_GREPSTART; \
133 o->op_ppaddr = PL_ppaddr[arg]; \
135 #define BSET_op_ppaddr(o, arg) Perl_croak(aTHX_ "op_ppaddr not yet implemented")
136 #define BSET_curpad(pad, arg) STMT_START { \
137 PL_comppad = (AV *)arg; \
138 pad = AvARRAY(arg); \
140 #define BSET_cop_file(cop, arg) CopFILE_set(cop,arg)
141 #define BSET_cop_line(cop, arg) CopLINE_set(cop,arg)
142 #define BSET_cop_stashpv(cop, arg) CopSTASHPV_set(cop,arg)
144 #define BSET_OBJ_STORE(obj, ix) \
145 (I32)ix > bytecode_obj_list_fill ? \
146 bset_obj_store(aTHXo_ obj, (I32)ix) : (bytecode_obj_list[ix] = obj)