1 typedef char *pvcontents;
2 typedef char *strconst;
4 typedef char *op_tr_array;
10 #ifdef INDIRECT_BGET_MACROS
11 #define BGET_FREAD(argp, len, nelem) \
12 bs.fread((char*)(argp),(len),(nelem),bs.data)
13 #define BGET_FGETC() bs.fgetc(bs.data)
15 #define BGET_FREAD(argp, len, nelem) PerlIO_read(fp, (argp), (len)*(nelem))
16 #define BGET_FGETC() PerlIO_getc(fp)
17 #endif /* INDIRECT_BGET_MACROS */
19 #define BGET_U32(arg) \
20 BGET_FREAD(&arg, sizeof(U32), 1); arg = PerlSock_ntohl((U32)arg)
21 #define BGET_I32(arg) \
22 BGET_FREAD(&arg, sizeof(I32), 1); arg = (I32)PerlSock_ntohl((U32)arg)
23 #define BGET_U16(arg) \
24 BGET_FREAD(&arg, sizeof(U16), 1); arg = PerlSock_ntohs((U16)arg)
25 #define BGET_U8(arg) arg = BGET_FGETC()
27 #if INDIRECT_BGET_MACROS
28 #define BGET_PV(arg) STMT_START { \
31 bs.freadpv(arg, bs.data); \
33 PL_bytecode_pv.xpv_pv = 0; \
34 PL_bytecode_pv.xpv_len = 0; \
35 PL_bytecode_pv.xpv_cur = 0; \
39 #define BGET_PV(arg) STMT_START { \
42 New(666, PL_bytecode_pv.xpv_pv, arg, char); \
43 PerlIO_read(fp, PL_bytecode_pv.xpv_pv, arg); \
44 PL_bytecode_pv.xpv_len = arg; \
45 PL_bytecode_pv.xpv_cur = arg - 1; \
47 PL_bytecode_pv.xpv_pv = 0; \
48 PL_bytecode_pv.xpv_len = 0; \
49 PL_bytecode_pv.xpv_cur = 0; \
52 #endif /* INDIRECT_BGET_MACROS */
54 #define BGET_comment_t(arg) \
55 do { arg = BGET_FGETC(); } while (arg != '\n' && arg != EOF)
58 * In the following, sizeof(IV)*4 is just a way of encoding 32 on 64-bit-IV
59 * machines such that 32-bit machine compilers don't whine about the shift
60 * count being too high even though the code is never reached there.
62 #define BGET_IV64(arg) STMT_START { \
66 if (sizeof(IV) == 8) \
67 arg = (IV) (hi << (sizeof(IV)*4) | lo); \
68 else if (((I32)hi == -1 && (I32)lo < 0) \
69 || ((I32)hi == 0 && (I32)lo >= 0)) { \
73 PL_bytecode_iv_overflows++; \
78 #define BGET_op_tr_array(arg) do { \
79 unsigned short *ary; \
81 New(666, ary, 256, unsigned short); \
82 BGET_FREAD(ary, 256, 2); \
83 for (i = 0; i < 256; i++) \
84 ary[i] = PerlSock_ntohs(ary[i]); \
88 #define BGET_pvcontents(arg) arg = PL_bytecode_pv.xpv_pv
89 #define BGET_strconst(arg) STMT_START { \
90 for (arg = PL_tokenbuf; (*arg = BGET_FGETC()); arg++) /* nothing */; \
94 #define BGET_double(arg) STMT_START { \
100 #define BGET_objindex(arg, type) STMT_START { \
103 arg = (type)PL_bytecode_obj_list[ix]; \
105 #define BGET_svindex(arg) BGET_objindex(arg, svindex)
106 #define BGET_opindex(arg) BGET_objindex(arg, opindex)
108 #define BSET_ldspecsv(sv, arg) sv = PL_specialsv_list[arg]
110 #define BSET_sv_refcnt_add(svrefcnt, arg) svrefcnt += arg
111 #define BSET_gp_refcnt_add(gprefcnt, arg) gprefcnt += arg
112 #define BSET_gp_share(sv, arg) STMT_START { \
114 GvGP(sv) = GvGP(arg); \
117 #define BSET_gv_fetchpv(sv, arg) sv = (SV*)gv_fetchpv(arg, TRUE, SVt_PV)
118 #define BSET_gv_stashpv(sv, arg) sv = (SV*)gv_stashpv(arg, TRUE)
119 #define BSET_sv_magic(sv, arg) sv_magic(sv, Nullsv, arg, 0, 0)
120 #define BSET_mg_pv(mg, arg) mg->mg_ptr = arg; mg->mg_len = PL_bytecode_pv.xpv_cur
121 #define BSET_sv_upgrade(sv, arg) (void)SvUPGRADE(sv, arg)
122 #define BSET_xpv(sv) do { \
123 SvPV_set(sv, PL_bytecode_pv.xpv_pv); \
124 SvCUR_set(sv, PL_bytecode_pv.xpv_cur); \
125 SvLEN_set(sv, PL_bytecode_pv.xpv_len); \
127 #define BSET_av_extend(sv, arg) av_extend((AV*)sv, arg)
129 #define BSET_av_push(sv, arg) av_push((AV*)sv, arg)
130 #define BSET_hv_store(sv, arg) \
131 hv_store((HV*)sv, PL_bytecode_pv.xpv_pv, PL_bytecode_pv.xpv_cur, arg, 0)
132 #define BSET_pv_free(pv) Safefree(pv.xpv_pv)
133 #define BSET_pregcomp(o, arg) \
134 ((PMOP*)o)->op_pmregexp = arg ? \
135 CALLREGCOMP(arg, arg + PL_bytecode_pv.xpv_cur, ((PMOP*)o)) : 0
136 #define BSET_newsv(sv, arg) sv = NEWSV(666,0); SvUPGRADE(sv, arg)
137 #define BSET_newop(o, arg) o = (OP*)safemalloc(optype_size[arg])
138 #define BSET_newopn(o, arg) STMT_START { \
140 BSET_newop(o, arg); \
141 oldop->op_next = o; \
144 #define BSET_ret(foo) return
147 * Kludge special-case workaround for OP_MAPSTART
148 * which needs the ppaddr for OP_GREPSTART. Blech.
150 #define BSET_op_type(o, arg) STMT_START { \
152 if (arg == OP_MAPSTART) \
153 arg = OP_GREPSTART; \
154 o->op_ppaddr = PL_ppaddr[arg]; \
156 #define BSET_op_ppaddr(o, arg) croak("op_ppaddr not yet implemented")
157 #define BSET_curpad(pad, arg) pad = AvARRAY(arg)
159 #define BSET_OBJ_STORE(obj, ix) \
160 (I32)ix > PL_bytecode_obj_list_fill ? \
161 bset_obj_store(obj, (I32)ix) : (PL_bytecode_obj_list[ix] = obj)