1 typedef char *pvcontents;
2 typedef char *strconst;
4 typedef char *op_tr_array;
10 EXT int iv_overflows INIT(0);
11 void *bset_obj_store _((void *, I32));
12 void freadpv _((U32, void *));
21 EXT I32 obj_list_fill INIT(-1);
23 #ifdef INDIRECT_BGET_MACROS
24 #define FREAD(argp, len, nelem) bs.fread((char*)(argp),(len),(nelem),bs.data)
25 #define FGETC() bs.fgetc(bs.data)
27 #define FREAD(argp, len, nelem) fread((argp), (len), (nelem), fp)
28 #define FGETC() getc(fp)
29 #endif /* INDIRECT_BGET_MACROS */
31 #define BGET_U32(arg) FREAD(&arg, sizeof(U32), 1); arg = ntohl((U32)arg)
32 #define BGET_I32(arg) FREAD(&arg, sizeof(I32), 1); arg = (I32)ntohl((U32)arg)
33 #define BGET_U16(arg) FREAD(&arg, sizeof(U16), 1); arg = ntohs((U16)arg)
34 #define BGET_U8(arg) arg = FGETC()
36 #if INDIRECT_BGET_MACROS
37 #define BGET_PV(arg) do { \
40 bs.freadpv(arg, bs.data); \
48 #define BGET_PV(arg) do { \
51 New(666, pv.xpv_pv, arg, char); \
52 fread(pv.xpv_pv, 1, arg, fp); \
54 pv.xpv_cur = arg - 1; \
61 #endif /* INDIRECT_BGET_MACROS */
63 #define BGET_comment(arg) \
64 do { arg = FGETC(); } while (arg != '\n' && arg != EOF)
67 * In the following, sizeof(IV)*4 is just a way of encoding 32 on 64-bit-IV
68 * machines such that 32-bit machine compilers don't whine about the shift
69 * count being too high even though the code is never reached there.
71 #define BGET_IV64(arg) do { \
75 if (sizeof(IV) == 8) \
76 arg = (IV) (hi << (sizeof(IV)*4) | lo); \
77 else if (((I32)hi == -1 && (I32)lo < 0) \
78 || ((I32)hi == 0 && (I32)lo >= 0)) { \
87 #define BGET_op_tr_array(arg) do { \
88 unsigned short *ary; \
90 New(666, ary, 256, unsigned short); \
92 for (i = 0; i < 256; i++) \
93 ary[i] = ntohs(ary[i]); \
97 #define BGET_pvcontents(arg) arg = pv.xpv_pv
98 #define BGET_strconst(arg) do { \
99 for (arg = tokenbuf; (*arg = FGETC()); arg++) /* nothing */; \
103 #define BGET_double(arg) do { \
105 BGET_strconst(str); \
109 #define BGET_objindex(arg) do { \
112 arg = obj_list[ix]; \
115 #define BSET_ldspecsv(sv, arg) sv = specialsv_list[arg]
117 #define BSET_sv_refcnt_add(svrefcnt, arg) svrefcnt += arg
118 #define BSET_gp_refcnt_add(gprefcnt, arg) gprefcnt += arg
119 #define BSET_gp_share(sv, arg) do { \
121 GvGP(sv) = GvGP(arg); \
124 #define BSET_gv_fetchpv(sv, arg) sv = (SV*)gv_fetchpv(arg, TRUE, SVt_PV)
125 #define BSET_gv_stashpv(sv, arg) sv = (SV*)gv_stashpv(arg, TRUE)
126 #define BSET_sv_magic(sv, arg) sv_magic(sv, Nullsv, arg, 0, 0)
127 #define BSET_mg_pv(mg, arg) mg->mg_ptr = arg; mg->mg_len = pv.xpv_cur
128 #define BSET_sv_upgrade(sv, arg) (void)SvUPGRADE(sv, arg)
129 #define BSET_xpv(sv) do { \
130 SvPV_set(sv, pv.xpv_pv); \
131 SvCUR_set(sv, pv.xpv_cur); \
132 SvLEN_set(sv, pv.xpv_len); \
134 #define BSET_av_extend(sv, arg) av_extend((AV*)sv, arg)
136 #define BSET_av_push(sv, arg) av_push((AV*)sv, arg)
137 #define BSET_hv_store(sv, arg) \
138 hv_store((HV*)sv, pv.xpv_pv, pv.xpv_cur, arg, 0)
139 #define BSET_pv_free(pv) Safefree(pv.xpv_pv)
140 #define BSET_pregcomp(o, arg) \
141 ((PMOP*)o)->op_pmregexp = arg ? \
142 pregcomp(arg, arg + pv.xpv_cur, ((PMOP*)o)) : 0
143 #define BSET_newsv(sv, arg) sv = NEWSV(666,0); SvUPGRADE(sv, arg)
144 #define BSET_newop(o, arg) o = (OP*)safemalloc(optype_size[arg])
145 #define BSET_newopn(o, arg) do { \
147 BSET_newop(o, arg); \
148 oldop->op_next = o; \
151 #define BSET_ret(foo) return
154 * Kludge special-case workaround for OP_MAPSTART
155 * which needs the ppaddr for OP_GREPSTART. Blech.
157 #define BSET_op_type(o, arg) do { \
159 if (arg == OP_MAPSTART) \
160 arg = OP_GREPSTART; \
161 o->op_ppaddr = ppaddr[arg]; \
163 #define BSET_op_ppaddr(o, arg) croak("op_ppaddr not yet implemented")
164 #define BSET_curpad(pad, arg) pad = AvARRAY(arg)
166 #define BSET_OBJ_STORE(obj, ix) \
167 (I32)ix > obj_list_fill ? \
168 bset_obj_store(obj, (I32)ix) : (obj_list[ix] = obj)