Commit | Line | Data |
---|---|---|
a8a597b2 MB |
1 | /* B.xs |
2 | * | |
3 | * Copyright (c) 1996 Malcolm Beattie | |
4 | * | |
5 | * You may distribute under the terms of either the GNU General Public | |
6 | * License or the Artistic License, as specified in the README file. | |
7 | * | |
8 | */ | |
9 | ||
c5be433b | 10 | #define PERL_NO_GET_CONTEXT |
a8a597b2 MB |
11 | #include "EXTERN.h" |
12 | #include "perl.h" | |
13 | #include "XSUB.h" | |
a8a597b2 | 14 | |
51aa15f3 | 15 | #ifdef PERL_OBJECT |
22c35a8c GS |
16 | #undef PL_op_name |
17 | #undef PL_opargs | |
18 | #undef PL_op_desc | |
0cb96387 GS |
19 | #define PL_op_name (get_op_names()) |
20 | #define PL_opargs (get_opargs()) | |
21 | #define PL_op_desc (get_op_descs()) | |
51aa15f3 GS |
22 | #endif |
23 | ||
24 | #ifdef PerlIO | |
25 | typedef PerlIO * InputStream; | |
26 | #else | |
27 | typedef FILE * InputStream; | |
28 | #endif | |
29 | ||
30 | ||
a8a597b2 MB |
31 | static char *svclassnames[] = { |
32 | "B::NULL", | |
33 | "B::IV", | |
34 | "B::NV", | |
35 | "B::RV", | |
36 | "B::PV", | |
37 | "B::PVIV", | |
38 | "B::PVNV", | |
39 | "B::PVMG", | |
40 | "B::BM", | |
41 | "B::PVLV", | |
42 | "B::AV", | |
43 | "B::HV", | |
44 | "B::CV", | |
45 | "B::GV", | |
46 | "B::FM", | |
47 | "B::IO", | |
48 | }; | |
49 | ||
50 | typedef enum { | |
51 | OPc_NULL, /* 0 */ | |
52 | OPc_BASEOP, /* 1 */ | |
53 | OPc_UNOP, /* 2 */ | |
54 | OPc_BINOP, /* 3 */ | |
55 | OPc_LOGOP, /* 4 */ | |
1a67a97c SM |
56 | OPc_LISTOP, /* 5 */ |
57 | OPc_PMOP, /* 6 */ | |
58 | OPc_SVOP, /* 7 */ | |
7934575e | 59 | OPc_PADOP, /* 8 */ |
1a67a97c SM |
60 | OPc_PVOP, /* 9 */ |
61 | OPc_CVOP, /* 10 */ | |
62 | OPc_LOOP, /* 11 */ | |
63 | OPc_COP /* 12 */ | |
a8a597b2 MB |
64 | } opclass; |
65 | ||
66 | static char *opclassnames[] = { | |
67 | "B::NULL", | |
68 | "B::OP", | |
69 | "B::UNOP", | |
70 | "B::BINOP", | |
71 | "B::LOGOP", | |
a8a597b2 MB |
72 | "B::LISTOP", |
73 | "B::PMOP", | |
74 | "B::SVOP", | |
7934575e | 75 | "B::PADOP", |
a8a597b2 MB |
76 | "B::PVOP", |
77 | "B::CVOP", | |
78 | "B::LOOP", | |
79 | "B::COP" | |
80 | }; | |
81 | ||
82 | static int walkoptree_debug = 0; /* Flag for walkoptree debug hook */ | |
83 | ||
059a8bb7 | 84 | static SV *specialsv_list[6]; |
e8edd1e6 | 85 | |
a8a597b2 | 86 | static opclass |
cea2e8a9 | 87 | cc_opclass(pTHX_ OP *o) |
a8a597b2 MB |
88 | { |
89 | if (!o) | |
90 | return OPc_NULL; | |
91 | ||
92 | if (o->op_type == 0) | |
93 | return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP; | |
94 | ||
95 | if (o->op_type == OP_SASSIGN) | |
96 | return ((o->op_private & OPpASSIGN_BACKWARDS) ? OPc_UNOP : OPc_BINOP); | |
97 | ||
18228111 GS |
98 | #ifdef USE_ITHREADS |
99 | if (o->op_type == OP_GV || o->op_type == OP_GVSV || o->op_type == OP_AELEMFAST) | |
100 | return OPc_PADOP; | |
101 | #endif | |
102 | ||
22c35a8c | 103 | switch (PL_opargs[o->op_type] & OA_CLASS_MASK) { |
a8a597b2 MB |
104 | case OA_BASEOP: |
105 | return OPc_BASEOP; | |
106 | ||
107 | case OA_UNOP: | |
108 | return OPc_UNOP; | |
109 | ||
110 | case OA_BINOP: | |
111 | return OPc_BINOP; | |
112 | ||
113 | case OA_LOGOP: | |
114 | return OPc_LOGOP; | |
115 | ||
a8a597b2 MB |
116 | case OA_LISTOP: |
117 | return OPc_LISTOP; | |
118 | ||
119 | case OA_PMOP: | |
120 | return OPc_PMOP; | |
121 | ||
122 | case OA_SVOP: | |
123 | return OPc_SVOP; | |
124 | ||
7934575e GS |
125 | case OA_PADOP: |
126 | return OPc_PADOP; | |
a8a597b2 | 127 | |
293d3ffa SM |
128 | case OA_PVOP_OR_SVOP: |
129 | /* | |
130 | * Character translations (tr///) are usually a PVOP, keeping a | |
131 | * pointer to a table of shorts used to look up translations. | |
132 | * Under utf8, however, a simple table isn't practical; instead, | |
133 | * the OP is an SVOP, and the SV is a reference to a swash | |
134 | * (i.e., an RV pointing to an HV). | |
135 | */ | |
136 | return (o->op_private & (OPpTRANS_TO_UTF|OPpTRANS_FROM_UTF)) | |
137 | ? OPc_SVOP : OPc_PVOP; | |
a8a597b2 MB |
138 | |
139 | case OA_LOOP: | |
140 | return OPc_LOOP; | |
141 | ||
142 | case OA_COP: | |
143 | return OPc_COP; | |
144 | ||
145 | case OA_BASEOP_OR_UNOP: | |
146 | /* | |
147 | * UNI(OP_foo) in toke.c returns token UNI or FUNC1 depending on | |
45f6cd40 SM |
148 | * whether parens were seen. perly.y uses OPf_SPECIAL to |
149 | * signal whether a BASEOP had empty parens or none. | |
150 | * Some other UNOPs are created later, though, so the best | |
151 | * test is OPf_KIDS, which is set in newUNOP. | |
a8a597b2 | 152 | */ |
45f6cd40 | 153 | return (o->op_flags & OPf_KIDS) ? OPc_UNOP : OPc_BASEOP; |
a8a597b2 MB |
154 | |
155 | case OA_FILESTATOP: | |
156 | /* | |
157 | * The file stat OPs are created via UNI(OP_foo) in toke.c but use | |
158 | * the OPf_REF flag to distinguish between OP types instead of the | |
159 | * usual OPf_SPECIAL flag. As usual, if OPf_KIDS is set, then we | |
160 | * return OPc_UNOP so that walkoptree can find our children. If | |
161 | * OPf_KIDS is not set then we check OPf_REF. Without OPf_REF set | |
162 | * (no argument to the operator) it's an OP; with OPf_REF set it's | |
7934575e | 163 | * an SVOP (and op_sv is the GV for the filehandle argument). |
a8a597b2 MB |
164 | */ |
165 | return ((o->op_flags & OPf_KIDS) ? OPc_UNOP : | |
93865851 GS |
166 | #ifdef USE_ITHREADS |
167 | (o->op_flags & OPf_REF) ? OPc_PADOP : OPc_BASEOP); | |
168 | #else | |
7934575e | 169 | (o->op_flags & OPf_REF) ? OPc_SVOP : OPc_BASEOP); |
93865851 | 170 | #endif |
a8a597b2 MB |
171 | case OA_LOOPEXOP: |
172 | /* | |
173 | * next, last, redo, dump and goto use OPf_SPECIAL to indicate that a | |
174 | * label was omitted (in which case it's a BASEOP) or else a term was | |
175 | * seen. In this last case, all except goto are definitely PVOP but | |
176 | * goto is either a PVOP (with an ordinary constant label), an UNOP | |
177 | * with OPf_STACKED (with a non-constant non-sub) or an UNOP for | |
178 | * OP_REFGEN (with goto &sub) in which case OPf_STACKED also seems to | |
179 | * get set. | |
180 | */ | |
181 | if (o->op_flags & OPf_STACKED) | |
182 | return OPc_UNOP; | |
183 | else if (o->op_flags & OPf_SPECIAL) | |
184 | return OPc_BASEOP; | |
185 | else | |
186 | return OPc_PVOP; | |
187 | } | |
188 | warn("can't determine class of operator %s, assuming BASEOP\n", | |
22c35a8c | 189 | PL_op_name[o->op_type]); |
a8a597b2 MB |
190 | return OPc_BASEOP; |
191 | } | |
192 | ||
193 | static char * | |
cea2e8a9 | 194 | cc_opclassname(pTHX_ OP *o) |
a8a597b2 | 195 | { |
cea2e8a9 | 196 | return opclassnames[cc_opclass(aTHX_ o)]; |
a8a597b2 MB |
197 | } |
198 | ||
199 | static SV * | |
cea2e8a9 | 200 | make_sv_object(pTHX_ SV *arg, SV *sv) |
a8a597b2 MB |
201 | { |
202 | char *type = 0; | |
203 | IV iv; | |
204 | ||
e8edd1e6 TH |
205 | for (iv = 0; iv < sizeof(specialsv_list)/sizeof(SV*); iv++) { |
206 | if (sv == specialsv_list[iv]) { | |
a8a597b2 MB |
207 | type = "B::SPECIAL"; |
208 | break; | |
209 | } | |
210 | } | |
211 | if (!type) { | |
212 | type = svclassnames[SvTYPE(sv)]; | |
56431972 | 213 | iv = PTR2IV(sv); |
a8a597b2 MB |
214 | } |
215 | sv_setiv(newSVrv(arg, type), iv); | |
216 | return arg; | |
217 | } | |
218 | ||
219 | static SV * | |
cea2e8a9 | 220 | make_mg_object(pTHX_ SV *arg, MAGIC *mg) |
a8a597b2 | 221 | { |
56431972 | 222 | sv_setiv(newSVrv(arg, "B::MAGIC"), PTR2IV(mg)); |
a8a597b2 MB |
223 | return arg; |
224 | } | |
225 | ||
226 | static SV * | |
cea2e8a9 | 227 | cstring(pTHX_ SV *sv) |
a8a597b2 | 228 | { |
79cb57f6 | 229 | SV *sstr = newSVpvn("", 0); |
a8a597b2 MB |
230 | STRLEN len; |
231 | char *s; | |
232 | ||
233 | if (!SvOK(sv)) | |
234 | sv_setpvn(sstr, "0", 1); | |
235 | else | |
236 | { | |
237 | /* XXX Optimise? */ | |
238 | s = SvPV(sv, len); | |
239 | sv_catpv(sstr, "\""); | |
240 | for (; len; len--, s++) | |
241 | { | |
242 | /* At least try a little for readability */ | |
243 | if (*s == '"') | |
244 | sv_catpv(sstr, "\\\""); | |
245 | else if (*s == '\\') | |
246 | sv_catpv(sstr, "\\\\"); | |
247 | else if (*s >= ' ' && *s < 127) /* XXX not portable */ | |
248 | sv_catpvn(sstr, s, 1); | |
249 | else if (*s == '\n') | |
250 | sv_catpv(sstr, "\\n"); | |
251 | else if (*s == '\r') | |
252 | sv_catpv(sstr, "\\r"); | |
253 | else if (*s == '\t') | |
254 | sv_catpv(sstr, "\\t"); | |
255 | else if (*s == '\a') | |
256 | sv_catpv(sstr, "\\a"); | |
257 | else if (*s == '\b') | |
258 | sv_catpv(sstr, "\\b"); | |
259 | else if (*s == '\f') | |
260 | sv_catpv(sstr, "\\f"); | |
261 | else if (*s == '\v') | |
262 | sv_catpv(sstr, "\\v"); | |
263 | else | |
264 | { | |
265 | /* no trigraph support */ | |
266 | char escbuff[5]; /* to fit backslash, 3 octals + trailing \0 */ | |
267 | /* Don't want promotion of a signed -1 char in sprintf args */ | |
268 | unsigned char c = (unsigned char) *s; | |
269 | sprintf(escbuff, "\\%03o", c); | |
270 | sv_catpv(sstr, escbuff); | |
271 | } | |
272 | /* XXX Add line breaks if string is long */ | |
273 | } | |
274 | sv_catpv(sstr, "\""); | |
275 | } | |
276 | return sstr; | |
277 | } | |
278 | ||
279 | static SV * | |
cea2e8a9 | 280 | cchar(pTHX_ SV *sv) |
a8a597b2 | 281 | { |
79cb57f6 | 282 | SV *sstr = newSVpvn("'", 1); |
2d8e6c8d GS |
283 | STRLEN n_a; |
284 | char *s = SvPV(sv, n_a); | |
a8a597b2 MB |
285 | |
286 | if (*s == '\'') | |
287 | sv_catpv(sstr, "\\'"); | |
288 | else if (*s == '\\') | |
289 | sv_catpv(sstr, "\\\\"); | |
290 | else if (*s >= ' ' && *s < 127) /* XXX not portable */ | |
291 | sv_catpvn(sstr, s, 1); | |
292 | else if (*s == '\n') | |
293 | sv_catpv(sstr, "\\n"); | |
294 | else if (*s == '\r') | |
295 | sv_catpv(sstr, "\\r"); | |
296 | else if (*s == '\t') | |
297 | sv_catpv(sstr, "\\t"); | |
298 | else if (*s == '\a') | |
299 | sv_catpv(sstr, "\\a"); | |
300 | else if (*s == '\b') | |
301 | sv_catpv(sstr, "\\b"); | |
302 | else if (*s == '\f') | |
303 | sv_catpv(sstr, "\\f"); | |
304 | else if (*s == '\v') | |
305 | sv_catpv(sstr, "\\v"); | |
306 | else | |
307 | { | |
308 | /* no trigraph support */ | |
309 | char escbuff[5]; /* to fit backslash, 3 octals + trailing \0 */ | |
310 | /* Don't want promotion of a signed -1 char in sprintf args */ | |
311 | unsigned char c = (unsigned char) *s; | |
312 | sprintf(escbuff, "\\%03o", c); | |
313 | sv_catpv(sstr, escbuff); | |
314 | } | |
315 | sv_catpv(sstr, "'"); | |
316 | return sstr; | |
317 | } | |
318 | ||
a8a597b2 | 319 | void |
cea2e8a9 | 320 | walkoptree(pTHX_ SV *opsv, char *method) |
a8a597b2 MB |
321 | { |
322 | dSP; | |
323 | OP *o; | |
324 | ||
325 | if (!SvROK(opsv)) | |
326 | croak("opsv is not a reference"); | |
327 | opsv = sv_mortalcopy(opsv); | |
56431972 | 328 | o = INT2PTR(OP*,SvIV((SV*)SvRV(opsv))); |
a8a597b2 MB |
329 | if (walkoptree_debug) { |
330 | PUSHMARK(sp); | |
331 | XPUSHs(opsv); | |
332 | PUTBACK; | |
333 | perl_call_method("walkoptree_debug", G_DISCARD); | |
334 | } | |
335 | PUSHMARK(sp); | |
336 | XPUSHs(opsv); | |
337 | PUTBACK; | |
338 | perl_call_method(method, G_DISCARD); | |
339 | if (o && (o->op_flags & OPf_KIDS)) { | |
340 | OP *kid; | |
341 | for (kid = ((UNOP*)o)->op_first; kid; kid = kid->op_sibling) { | |
342 | /* Use the same opsv. Rely on methods not to mess it up. */ | |
56431972 | 343 | sv_setiv(newSVrv(opsv, cc_opclassname(aTHX_ kid)), PTR2IV(kid)); |
cea2e8a9 | 344 | walkoptree(aTHX_ opsv, method); |
a8a597b2 MB |
345 | } |
346 | } | |
347 | } | |
348 | ||
349 | typedef OP *B__OP; | |
350 | typedef UNOP *B__UNOP; | |
351 | typedef BINOP *B__BINOP; | |
352 | typedef LOGOP *B__LOGOP; | |
a8a597b2 MB |
353 | typedef LISTOP *B__LISTOP; |
354 | typedef PMOP *B__PMOP; | |
355 | typedef SVOP *B__SVOP; | |
7934575e | 356 | typedef PADOP *B__PADOP; |
a8a597b2 MB |
357 | typedef PVOP *B__PVOP; |
358 | typedef LOOP *B__LOOP; | |
359 | typedef COP *B__COP; | |
360 | ||
361 | typedef SV *B__SV; | |
362 | typedef SV *B__IV; | |
363 | typedef SV *B__PV; | |
364 | typedef SV *B__NV; | |
365 | typedef SV *B__PVMG; | |
366 | typedef SV *B__PVLV; | |
367 | typedef SV *B__BM; | |
368 | typedef SV *B__RV; | |
369 | typedef AV *B__AV; | |
370 | typedef HV *B__HV; | |
371 | typedef CV *B__CV; | |
372 | typedef GV *B__GV; | |
373 | typedef IO *B__IO; | |
374 | ||
375 | typedef MAGIC *B__MAGIC; | |
376 | ||
377 | MODULE = B PACKAGE = B PREFIX = B_ | |
378 | ||
379 | PROTOTYPES: DISABLE | |
380 | ||
381 | BOOT: | |
4c1f658f NIS |
382 | { |
383 | HV *stash = gv_stashpvn("B", 1, TRUE); | |
384 | AV *export_ok = perl_get_av("B::EXPORT_OK",TRUE); | |
e8edd1e6 TH |
385 | specialsv_list[0] = Nullsv; |
386 | specialsv_list[1] = &PL_sv_undef; | |
387 | specialsv_list[2] = &PL_sv_yes; | |
388 | specialsv_list[3] = &PL_sv_no; | |
059a8bb7 JH |
389 | specialsv_list[4] = pWARN_ALL; |
390 | specialsv_list[5] = pWARN_NONE; | |
4c1f658f NIS |
391 | #include "defsubs.h" |
392 | } | |
a8a597b2 | 393 | |
3280af22 | 394 | #define B_main_cv() PL_main_cv |
31d7d75a | 395 | #define B_init_av() PL_initav |
059a8bb7 JH |
396 | #define B_begin_av() PL_beginav_save |
397 | #define B_end_av() PL_endav | |
3280af22 NIS |
398 | #define B_main_root() PL_main_root |
399 | #define B_main_start() PL_main_start | |
56eca212 | 400 | #define B_amagic_generation() PL_amagic_generation |
3280af22 NIS |
401 | #define B_comppadlist() (PL_main_cv ? CvPADLIST(PL_main_cv) : CvPADLIST(PL_compcv)) |
402 | #define B_sv_undef() &PL_sv_undef | |
403 | #define B_sv_yes() &PL_sv_yes | |
404 | #define B_sv_no() &PL_sv_no | |
a8a597b2 | 405 | |
31d7d75a NIS |
406 | B::AV |
407 | B_init_av() | |
408 | ||
059a8bb7 JH |
409 | B::AV |
410 | B_begin_av() | |
411 | ||
412 | B::AV | |
413 | B_end_av() | |
414 | ||
a8a597b2 MB |
415 | B::CV |
416 | B_main_cv() | |
417 | ||
418 | B::OP | |
419 | B_main_root() | |
420 | ||
421 | B::OP | |
422 | B_main_start() | |
423 | ||
56eca212 GS |
424 | long |
425 | B_amagic_generation() | |
426 | ||
a8a597b2 MB |
427 | B::AV |
428 | B_comppadlist() | |
429 | ||
430 | B::SV | |
431 | B_sv_undef() | |
432 | ||
433 | B::SV | |
434 | B_sv_yes() | |
435 | ||
436 | B::SV | |
437 | B_sv_no() | |
438 | ||
439 | MODULE = B PACKAGE = B | |
440 | ||
441 | ||
442 | void | |
443 | walkoptree(opsv, method) | |
444 | SV * opsv | |
445 | char * method | |
cea2e8a9 GS |
446 | CODE: |
447 | walkoptree(aTHX_ opsv, method); | |
a8a597b2 MB |
448 | |
449 | int | |
450 | walkoptree_debug(...) | |
451 | CODE: | |
452 | RETVAL = walkoptree_debug; | |
453 | if (items > 0 && SvTRUE(ST(1))) | |
454 | walkoptree_debug = 1; | |
455 | OUTPUT: | |
456 | RETVAL | |
457 | ||
56431972 | 458 | #define address(sv) PTR2IV(sv) |
a8a597b2 MB |
459 | |
460 | IV | |
461 | address(sv) | |
462 | SV * sv | |
463 | ||
464 | B::SV | |
465 | svref_2object(sv) | |
466 | SV * sv | |
467 | CODE: | |
468 | if (!SvROK(sv)) | |
469 | croak("argument is not a reference"); | |
470 | RETVAL = (SV*)SvRV(sv); | |
471 | OUTPUT: | |
0cc1d052 NIS |
472 | RETVAL |
473 | ||
474 | void | |
475 | opnumber(name) | |
476 | char * name | |
477 | CODE: | |
478 | { | |
479 | int i; | |
480 | IV result = -1; | |
481 | ST(0) = sv_newmortal(); | |
482 | if (strncmp(name,"pp_",3) == 0) | |
483 | name += 3; | |
484 | for (i = 0; i < PL_maxo; i++) | |
485 | { | |
486 | if (strcmp(name, PL_op_name[i]) == 0) | |
487 | { | |
488 | result = i; | |
489 | break; | |
490 | } | |
491 | } | |
492 | sv_setiv(ST(0),result); | |
493 | } | |
a8a597b2 MB |
494 | |
495 | void | |
496 | ppname(opnum) | |
497 | int opnum | |
498 | CODE: | |
499 | ST(0) = sv_newmortal(); | |
3280af22 | 500 | if (opnum >= 0 && opnum < PL_maxo) { |
a8a597b2 | 501 | sv_setpvn(ST(0), "pp_", 3); |
22c35a8c | 502 | sv_catpv(ST(0), PL_op_name[opnum]); |
a8a597b2 MB |
503 | } |
504 | ||
505 | void | |
506 | hash(sv) | |
507 | SV * sv | |
508 | CODE: | |
509 | char *s; | |
510 | STRLEN len; | |
511 | U32 hash = 0; | |
faccc32b | 512 | char hexhash[19]; /* must fit "0xffffffffffffffff" plus trailing \0 */ |
a8a597b2 | 513 | s = SvPV(sv, len); |
cf86991c | 514 | PERL_HASH(hash, s, len); |
faccc32b | 515 | sprintf(hexhash, "0x%"UVxf, (UV)hash); |
a8a597b2 MB |
516 | ST(0) = sv_2mortal(newSVpv(hexhash, 0)); |
517 | ||
518 | #define cast_I32(foo) (I32)foo | |
519 | IV | |
520 | cast_I32(i) | |
521 | IV i | |
522 | ||
523 | void | |
524 | minus_c() | |
525 | CODE: | |
3280af22 | 526 | PL_minus_c = TRUE; |
a8a597b2 | 527 | |
059a8bb7 JH |
528 | void |
529 | save_BEGINs() | |
530 | CODE: | |
531 | PL_minus_c |= 0x10; | |
532 | ||
a8a597b2 MB |
533 | SV * |
534 | cstring(sv) | |
535 | SV * sv | |
cea2e8a9 GS |
536 | CODE: |
537 | RETVAL = cstring(aTHX_ sv); | |
538 | OUTPUT: | |
539 | RETVAL | |
a8a597b2 MB |
540 | |
541 | SV * | |
542 | cchar(sv) | |
543 | SV * sv | |
cea2e8a9 GS |
544 | CODE: |
545 | RETVAL = cchar(aTHX_ sv); | |
546 | OUTPUT: | |
547 | RETVAL | |
a8a597b2 MB |
548 | |
549 | void | |
550 | threadsv_names() | |
551 | PPCODE: | |
552 | #ifdef USE_THREADS | |
553 | int i; | |
533c011a | 554 | STRLEN len = strlen(PL_threadsv_names); |
a8a597b2 MB |
555 | |
556 | EXTEND(sp, len); | |
557 | for (i = 0; i < len; i++) | |
79cb57f6 | 558 | PUSHs(sv_2mortal(newSVpvn(&PL_threadsv_names[i], 1))); |
a8a597b2 MB |
559 | #endif |
560 | ||
561 | ||
562 | #define OP_next(o) o->op_next | |
563 | #define OP_sibling(o) o->op_sibling | |
22c35a8c | 564 | #define OP_desc(o) PL_op_desc[o->op_type] |
a8a597b2 MB |
565 | #define OP_targ(o) o->op_targ |
566 | #define OP_type(o) o->op_type | |
567 | #define OP_seq(o) o->op_seq | |
568 | #define OP_flags(o) o->op_flags | |
569 | #define OP_private(o) o->op_private | |
570 | ||
571 | MODULE = B PACKAGE = B::OP PREFIX = OP_ | |
572 | ||
573 | B::OP | |
574 | OP_next(o) | |
575 | B::OP o | |
576 | ||
577 | B::OP | |
578 | OP_sibling(o) | |
579 | B::OP o | |
580 | ||
581 | char * | |
3f872cb9 GS |
582 | OP_name(o) |
583 | B::OP o | |
584 | CODE: | |
585 | ST(0) = sv_newmortal(); | |
586 | sv_setpv(ST(0), PL_op_name[o->op_type]); | |
587 | ||
588 | ||
589 | char * | |
a8a597b2 MB |
590 | OP_ppaddr(o) |
591 | B::OP o | |
dc333d64 GS |
592 | PREINIT: |
593 | int i; | |
594 | SV *sv = sv_newmortal(); | |
a8a597b2 | 595 | CODE: |
dc333d64 GS |
596 | sv_setpvn(sv, "PL_ppaddr[OP_", 13); |
597 | sv_catpv(sv, PL_op_name[o->op_type]); | |
598 | for (i=13; i<SvCUR(sv); ++i) | |
599 | SvPVX(sv)[i] = toUPPER(SvPVX(sv)[i]); | |
600 | sv_catpv(sv, "]"); | |
601 | ST(0) = sv; | |
a8a597b2 MB |
602 | |
603 | char * | |
604 | OP_desc(o) | |
605 | B::OP o | |
606 | ||
7934575e | 607 | PADOFFSET |
a8a597b2 MB |
608 | OP_targ(o) |
609 | B::OP o | |
610 | ||
611 | U16 | |
612 | OP_type(o) | |
613 | B::OP o | |
614 | ||
615 | U16 | |
616 | OP_seq(o) | |
617 | B::OP o | |
618 | ||
619 | U8 | |
620 | OP_flags(o) | |
621 | B::OP o | |
622 | ||
623 | U8 | |
624 | OP_private(o) | |
625 | B::OP o | |
626 | ||
627 | #define UNOP_first(o) o->op_first | |
628 | ||
629 | MODULE = B PACKAGE = B::UNOP PREFIX = UNOP_ | |
630 | ||
631 | B::OP | |
632 | UNOP_first(o) | |
633 | B::UNOP o | |
634 | ||
635 | #define BINOP_last(o) o->op_last | |
636 | ||
637 | MODULE = B PACKAGE = B::BINOP PREFIX = BINOP_ | |
638 | ||
639 | B::OP | |
640 | BINOP_last(o) | |
641 | B::BINOP o | |
642 | ||
643 | #define LOGOP_other(o) o->op_other | |
644 | ||
645 | MODULE = B PACKAGE = B::LOGOP PREFIX = LOGOP_ | |
646 | ||
647 | B::OP | |
648 | LOGOP_other(o) | |
649 | B::LOGOP o | |
650 | ||
a8a597b2 MB |
651 | MODULE = B PACKAGE = B::LISTOP PREFIX = LISTOP_ |
652 | ||
a8a597b2 MB |
653 | #define PMOP_pmreplroot(o) o->op_pmreplroot |
654 | #define PMOP_pmreplstart(o) o->op_pmreplstart | |
655 | #define PMOP_pmnext(o) o->op_pmnext | |
656 | #define PMOP_pmregexp(o) o->op_pmregexp | |
657 | #define PMOP_pmflags(o) o->op_pmflags | |
658 | #define PMOP_pmpermflags(o) o->op_pmpermflags | |
659 | ||
660 | MODULE = B PACKAGE = B::PMOP PREFIX = PMOP_ | |
661 | ||
662 | void | |
663 | PMOP_pmreplroot(o) | |
664 | B::PMOP o | |
665 | OP * root = NO_INIT | |
666 | CODE: | |
667 | ST(0) = sv_newmortal(); | |
668 | root = o->op_pmreplroot; | |
669 | /* OP_PUSHRE stores an SV* instead of an OP* in op_pmreplroot */ | |
670 | if (o->op_type == OP_PUSHRE) { | |
671 | sv_setiv(newSVrv(ST(0), root ? | |
672 | svclassnames[SvTYPE((SV*)root)] : "B::SV"), | |
56431972 | 673 | PTR2IV(root)); |
a8a597b2 MB |
674 | } |
675 | else { | |
56431972 | 676 | sv_setiv(newSVrv(ST(0), cc_opclassname(aTHX_ root)), PTR2IV(root)); |
a8a597b2 MB |
677 | } |
678 | ||
679 | B::OP | |
680 | PMOP_pmreplstart(o) | |
681 | B::PMOP o | |
682 | ||
683 | B::PMOP | |
684 | PMOP_pmnext(o) | |
685 | B::PMOP o | |
686 | ||
687 | U16 | |
688 | PMOP_pmflags(o) | |
689 | B::PMOP o | |
690 | ||
691 | U16 | |
692 | PMOP_pmpermflags(o) | |
693 | B::PMOP o | |
694 | ||
695 | void | |
696 | PMOP_precomp(o) | |
697 | B::PMOP o | |
698 | REGEXP * rx = NO_INIT | |
699 | CODE: | |
700 | ST(0) = sv_newmortal(); | |
701 | rx = o->op_pmregexp; | |
702 | if (rx) | |
703 | sv_setpvn(ST(0), rx->precomp, rx->prelen); | |
704 | ||
ac33dcd1 JH |
705 | #define SVOP_sv(o) cSVOPo->op_sv |
706 | #define SVOP_gv(o) ((GV*)cSVOPo->op_sv) | |
a8a597b2 MB |
707 | |
708 | MODULE = B PACKAGE = B::SVOP PREFIX = SVOP_ | |
709 | ||
a8a597b2 MB |
710 | B::SV |
711 | SVOP_sv(o) | |
712 | B::SVOP o | |
713 | ||
f22444f5 | 714 | B::GV |
065a1863 GS |
715 | SVOP_gv(o) |
716 | B::SVOP o | |
717 | ||
7934575e GS |
718 | #define PADOP_padix(o) o->op_padix |
719 | #define PADOP_sv(o) (o->op_padix ? PL_curpad[o->op_padix] : Nullsv) | |
720 | #define PADOP_gv(o) ((o->op_padix \ | |
721 | && SvTYPE(PL_curpad[o->op_padix]) == SVt_PVGV) \ | |
722 | ? (GV*)PL_curpad[o->op_padix] : Nullgv) | |
a8a597b2 | 723 | |
7934575e GS |
724 | MODULE = B PACKAGE = B::PADOP PREFIX = PADOP_ |
725 | ||
726 | PADOFFSET | |
727 | PADOP_padix(o) | |
728 | B::PADOP o | |
729 | ||
730 | B::SV | |
731 | PADOP_sv(o) | |
732 | B::PADOP o | |
a8a597b2 MB |
733 | |
734 | B::GV | |
7934575e GS |
735 | PADOP_gv(o) |
736 | B::PADOP o | |
a8a597b2 MB |
737 | |
738 | MODULE = B PACKAGE = B::PVOP PREFIX = PVOP_ | |
739 | ||
740 | void | |
741 | PVOP_pv(o) | |
742 | B::PVOP o | |
743 | CODE: | |
744 | /* | |
745 | * OP_TRANS uses op_pv to point to a table of 256 shorts | |
746 | * whereas other PVOPs point to a null terminated string. | |
747 | */ | |
748 | ST(0) = sv_2mortal(newSVpv(o->op_pv, (o->op_type == OP_TRANS) ? | |
749 | 256 * sizeof(short) : 0)); | |
750 | ||
751 | #define LOOP_redoop(o) o->op_redoop | |
752 | #define LOOP_nextop(o) o->op_nextop | |
753 | #define LOOP_lastop(o) o->op_lastop | |
754 | ||
755 | MODULE = B PACKAGE = B::LOOP PREFIX = LOOP_ | |
756 | ||
757 | ||
758 | B::OP | |
759 | LOOP_redoop(o) | |
760 | B::LOOP o | |
761 | ||
762 | B::OP | |
763 | LOOP_nextop(o) | |
764 | B::LOOP o | |
765 | ||
766 | B::OP | |
767 | LOOP_lastop(o) | |
768 | B::LOOP o | |
769 | ||
770 | #define COP_label(o) o->cop_label | |
11faa288 GS |
771 | #define COP_stashpv(o) CopSTASHPV(o) |
772 | #define COP_stash(o) CopSTASH(o) | |
57843af0 | 773 | #define COP_file(o) CopFILE(o) |
a8a597b2 MB |
774 | #define COP_cop_seq(o) o->cop_seq |
775 | #define COP_arybase(o) o->cop_arybase | |
57843af0 | 776 | #define COP_line(o) CopLINE(o) |
b295d113 | 777 | #define COP_warnings(o) o->cop_warnings |
a8a597b2 MB |
778 | |
779 | MODULE = B PACKAGE = B::COP PREFIX = COP_ | |
780 | ||
781 | char * | |
782 | COP_label(o) | |
783 | B::COP o | |
784 | ||
11faa288 GS |
785 | char * |
786 | COP_stashpv(o) | |
787 | B::COP o | |
788 | ||
a8a597b2 MB |
789 | B::HV |
790 | COP_stash(o) | |
791 | B::COP o | |
792 | ||
57843af0 GS |
793 | char * |
794 | COP_file(o) | |
a8a597b2 MB |
795 | B::COP o |
796 | ||
797 | U32 | |
798 | COP_cop_seq(o) | |
799 | B::COP o | |
800 | ||
801 | I32 | |
802 | COP_arybase(o) | |
803 | B::COP o | |
804 | ||
805 | U16 | |
806 | COP_line(o) | |
807 | B::COP o | |
808 | ||
b295d113 TH |
809 | B::SV |
810 | COP_warnings(o) | |
811 | B::COP o | |
812 | ||
a8a597b2 MB |
813 | MODULE = B PACKAGE = B::SV PREFIX = Sv |
814 | ||
815 | U32 | |
816 | SvREFCNT(sv) | |
817 | B::SV sv | |
818 | ||
819 | U32 | |
820 | SvFLAGS(sv) | |
821 | B::SV sv | |
822 | ||
823 | MODULE = B PACKAGE = B::IV PREFIX = Sv | |
824 | ||
825 | IV | |
826 | SvIV(sv) | |
827 | B::IV sv | |
828 | ||
829 | IV | |
830 | SvIVX(sv) | |
831 | B::IV sv | |
832 | ||
0ca04487 VB |
833 | UV |
834 | SvUVX(sv) | |
835 | B::IV sv | |
836 | ||
837 | ||
a8a597b2 MB |
838 | MODULE = B PACKAGE = B::IV |
839 | ||
840 | #define needs64bits(sv) ((I32)SvIVX(sv) != SvIVX(sv)) | |
841 | ||
842 | int | |
843 | needs64bits(sv) | |
844 | B::IV sv | |
845 | ||
846 | void | |
847 | packiv(sv) | |
848 | B::IV sv | |
849 | CODE: | |
850 | if (sizeof(IV) == 8) { | |
851 | U32 wp[2]; | |
852 | IV iv = SvIVX(sv); | |
853 | /* | |
854 | * The following way of spelling 32 is to stop compilers on | |
855 | * 32-bit architectures from moaning about the shift count | |
856 | * being >= the width of the type. Such architectures don't | |
857 | * reach this code anyway (unless sizeof(IV) > 8 but then | |
858 | * everything else breaks too so I'm not fussed at the moment). | |
859 | */ | |
42718184 RB |
860 | #ifdef UV_IS_QUAD |
861 | wp[0] = htonl(((UV)iv) >> (sizeof(UV)*4)); | |
862 | #else | |
863 | wp[0] = htonl(((U32)iv) >> (sizeof(UV)*4)); | |
864 | #endif | |
a8a597b2 | 865 | wp[1] = htonl(iv & 0xffffffff); |
79cb57f6 | 866 | ST(0) = sv_2mortal(newSVpvn((char *)wp, 8)); |
a8a597b2 MB |
867 | } else { |
868 | U32 w = htonl((U32)SvIVX(sv)); | |
79cb57f6 | 869 | ST(0) = sv_2mortal(newSVpvn((char *)&w, 4)); |
a8a597b2 MB |
870 | } |
871 | ||
872 | MODULE = B PACKAGE = B::NV PREFIX = Sv | |
873 | ||
874 | double | |
875 | SvNV(sv) | |
876 | B::NV sv | |
877 | ||
878 | double | |
879 | SvNVX(sv) | |
880 | B::NV sv | |
881 | ||
882 | MODULE = B PACKAGE = B::RV PREFIX = Sv | |
883 | ||
884 | B::SV | |
885 | SvRV(sv) | |
886 | B::RV sv | |
887 | ||
888 | MODULE = B PACKAGE = B::PV PREFIX = Sv | |
889 | ||
890 | void | |
891 | SvPV(sv) | |
892 | B::PV sv | |
893 | CODE: | |
894 | ST(0) = sv_newmortal(); | |
895 | sv_setpvn(ST(0), SvPVX(sv), SvCUR(sv)); | |
896 | ||
445a12f6 DM |
897 | STRLEN |
898 | SvLEN(sv) | |
899 | B::PV sv | |
900 | ||
901 | STRLEN | |
902 | SvCUR(sv) | |
903 | B::PV sv | |
904 | ||
a8a597b2 MB |
905 | MODULE = B PACKAGE = B::PVMG PREFIX = Sv |
906 | ||
907 | void | |
908 | SvMAGIC(sv) | |
909 | B::PVMG sv | |
910 | MAGIC * mg = NO_INIT | |
911 | PPCODE: | |
912 | for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) | |
cea2e8a9 | 913 | XPUSHs(make_mg_object(aTHX_ sv_newmortal(), mg)); |
a8a597b2 MB |
914 | |
915 | MODULE = B PACKAGE = B::PVMG | |
916 | ||
917 | B::HV | |
918 | SvSTASH(sv) | |
919 | B::PVMG sv | |
920 | ||
921 | #define MgMOREMAGIC(mg) mg->mg_moremagic | |
922 | #define MgPRIVATE(mg) mg->mg_private | |
923 | #define MgTYPE(mg) mg->mg_type | |
924 | #define MgFLAGS(mg) mg->mg_flags | |
925 | #define MgOBJ(mg) mg->mg_obj | |
88b39979 | 926 | #define MgLENGTH(mg) mg->mg_len |
a8a597b2 MB |
927 | |
928 | MODULE = B PACKAGE = B::MAGIC PREFIX = Mg | |
929 | ||
930 | B::MAGIC | |
931 | MgMOREMAGIC(mg) | |
932 | B::MAGIC mg | |
933 | ||
934 | U16 | |
935 | MgPRIVATE(mg) | |
936 | B::MAGIC mg | |
937 | ||
938 | char | |
939 | MgTYPE(mg) | |
940 | B::MAGIC mg | |
941 | ||
942 | U8 | |
943 | MgFLAGS(mg) | |
944 | B::MAGIC mg | |
945 | ||
946 | B::SV | |
947 | MgOBJ(mg) | |
948 | B::MAGIC mg | |
949 | ||
88b39979 VB |
950 | I32 |
951 | MgLENGTH(mg) | |
952 | B::MAGIC mg | |
953 | ||
a8a597b2 MB |
954 | void |
955 | MgPTR(mg) | |
956 | B::MAGIC mg | |
957 | CODE: | |
958 | ST(0) = sv_newmortal(); | |
88b39979 VB |
959 | if (mg->mg_ptr){ |
960 | if (mg->mg_len >= 0){ | |
961 | sv_setpvn(ST(0), mg->mg_ptr, mg->mg_len); | |
962 | } else { | |
963 | if (mg->mg_len == HEf_SVKEY) | |
964 | sv_setsv(ST(0),newRV((SV*)mg->mg_ptr)); | |
965 | } | |
966 | } | |
a8a597b2 MB |
967 | |
968 | MODULE = B PACKAGE = B::PVLV PREFIX = Lv | |
969 | ||
970 | U32 | |
971 | LvTARGOFF(sv) | |
972 | B::PVLV sv | |
973 | ||
974 | U32 | |
975 | LvTARGLEN(sv) | |
976 | B::PVLV sv | |
977 | ||
978 | char | |
979 | LvTYPE(sv) | |
980 | B::PVLV sv | |
981 | ||
982 | B::SV | |
983 | LvTARG(sv) | |
984 | B::PVLV sv | |
985 | ||
986 | MODULE = B PACKAGE = B::BM PREFIX = Bm | |
987 | ||
988 | I32 | |
989 | BmUSEFUL(sv) | |
990 | B::BM sv | |
991 | ||
992 | U16 | |
993 | BmPREVIOUS(sv) | |
994 | B::BM sv | |
995 | ||
996 | U8 | |
997 | BmRARE(sv) | |
998 | B::BM sv | |
999 | ||
1000 | void | |
1001 | BmTABLE(sv) | |
1002 | B::BM sv | |
1003 | STRLEN len = NO_INIT | |
1004 | char * str = NO_INIT | |
1005 | CODE: | |
1006 | str = SvPV(sv, len); | |
1007 | /* Boyer-Moore table is just after string and its safety-margin \0 */ | |
79cb57f6 | 1008 | ST(0) = sv_2mortal(newSVpvn(str + len + 1, 256)); |
a8a597b2 MB |
1009 | |
1010 | MODULE = B PACKAGE = B::GV PREFIX = Gv | |
1011 | ||
1012 | void | |
1013 | GvNAME(gv) | |
1014 | B::GV gv | |
1015 | CODE: | |
79cb57f6 | 1016 | ST(0) = sv_2mortal(newSVpvn(GvNAME(gv), GvNAMELEN(gv))); |
a8a597b2 | 1017 | |
87d7fd28 GS |
1018 | bool |
1019 | is_empty(gv) | |
1020 | B::GV gv | |
1021 | CODE: | |
1022 | RETVAL = GvGP(gv) == Null(GP*); | |
1023 | OUTPUT: | |
1024 | RETVAL | |
1025 | ||
a8a597b2 MB |
1026 | B::HV |
1027 | GvSTASH(gv) | |
1028 | B::GV gv | |
1029 | ||
1030 | B::SV | |
1031 | GvSV(gv) | |
1032 | B::GV gv | |
1033 | ||
1034 | B::IO | |
1035 | GvIO(gv) | |
1036 | B::GV gv | |
1037 | ||
1038 | B::CV | |
1039 | GvFORM(gv) | |
1040 | B::GV gv | |
1041 | ||
1042 | B::AV | |
1043 | GvAV(gv) | |
1044 | B::GV gv | |
1045 | ||
1046 | B::HV | |
1047 | GvHV(gv) | |
1048 | B::GV gv | |
1049 | ||
1050 | B::GV | |
1051 | GvEGV(gv) | |
1052 | B::GV gv | |
1053 | ||
1054 | B::CV | |
1055 | GvCV(gv) | |
1056 | B::GV gv | |
1057 | ||
1058 | U32 | |
1059 | GvCVGEN(gv) | |
1060 | B::GV gv | |
1061 | ||
1062 | U16 | |
1063 | GvLINE(gv) | |
1064 | B::GV gv | |
1065 | ||
b195d487 GS |
1066 | char * |
1067 | GvFILE(gv) | |
1068 | B::GV gv | |
1069 | ||
a8a597b2 MB |
1070 | B::GV |
1071 | GvFILEGV(gv) | |
1072 | B::GV gv | |
1073 | ||
1074 | MODULE = B PACKAGE = B::GV | |
1075 | ||
1076 | U32 | |
1077 | GvREFCNT(gv) | |
1078 | B::GV gv | |
1079 | ||
1080 | U8 | |
1081 | GvFLAGS(gv) | |
1082 | B::GV gv | |
1083 | ||
1084 | MODULE = B PACKAGE = B::IO PREFIX = Io | |
1085 | ||
1086 | long | |
1087 | IoLINES(io) | |
1088 | B::IO io | |
1089 | ||
1090 | long | |
1091 | IoPAGE(io) | |
1092 | B::IO io | |
1093 | ||
1094 | long | |
1095 | IoPAGE_LEN(io) | |
1096 | B::IO io | |
1097 | ||
1098 | long | |
1099 | IoLINES_LEFT(io) | |
1100 | B::IO io | |
1101 | ||
1102 | char * | |
1103 | IoTOP_NAME(io) | |
1104 | B::IO io | |
1105 | ||
1106 | B::GV | |
1107 | IoTOP_GV(io) | |
1108 | B::IO io | |
1109 | ||
1110 | char * | |
1111 | IoFMT_NAME(io) | |
1112 | B::IO io | |
1113 | ||
1114 | B::GV | |
1115 | IoFMT_GV(io) | |
1116 | B::IO io | |
1117 | ||
1118 | char * | |
1119 | IoBOTTOM_NAME(io) | |
1120 | B::IO io | |
1121 | ||
1122 | B::GV | |
1123 | IoBOTTOM_GV(io) | |
1124 | B::IO io | |
1125 | ||
1126 | short | |
1127 | IoSUBPROCESS(io) | |
1128 | B::IO io | |
1129 | ||
1130 | MODULE = B PACKAGE = B::IO | |
1131 | ||
1132 | char | |
1133 | IoTYPE(io) | |
1134 | B::IO io | |
1135 | ||
1136 | U8 | |
1137 | IoFLAGS(io) | |
1138 | B::IO io | |
1139 | ||
1140 | MODULE = B PACKAGE = B::AV PREFIX = Av | |
1141 | ||
1142 | SSize_t | |
1143 | AvFILL(av) | |
1144 | B::AV av | |
1145 | ||
1146 | SSize_t | |
1147 | AvMAX(av) | |
1148 | B::AV av | |
1149 | ||
1150 | #define AvOFF(av) ((XPVAV*)SvANY(av))->xof_off | |
1151 | ||
1152 | IV | |
1153 | AvOFF(av) | |
1154 | B::AV av | |
1155 | ||
1156 | void | |
1157 | AvARRAY(av) | |
1158 | B::AV av | |
1159 | PPCODE: | |
1160 | if (AvFILL(av) >= 0) { | |
1161 | SV **svp = AvARRAY(av); | |
1162 | I32 i; | |
1163 | for (i = 0; i <= AvFILL(av); i++) | |
cea2e8a9 | 1164 | XPUSHs(make_sv_object(aTHX_ sv_newmortal(), svp[i])); |
a8a597b2 MB |
1165 | } |
1166 | ||
1167 | MODULE = B PACKAGE = B::AV | |
1168 | ||
1169 | U8 | |
1170 | AvFLAGS(av) | |
1171 | B::AV av | |
1172 | ||
1173 | MODULE = B PACKAGE = B::CV PREFIX = Cv | |
1174 | ||
1175 | B::HV | |
1176 | CvSTASH(cv) | |
1177 | B::CV cv | |
1178 | ||
1179 | B::OP | |
1180 | CvSTART(cv) | |
1181 | B::CV cv | |
1182 | ||
1183 | B::OP | |
1184 | CvROOT(cv) | |
1185 | B::CV cv | |
1186 | ||
1187 | B::GV | |
1188 | CvGV(cv) | |
1189 | B::CV cv | |
1190 | ||
57843af0 GS |
1191 | char * |
1192 | CvFILE(cv) | |
1193 | B::CV cv | |
1194 | ||
a8a597b2 MB |
1195 | long |
1196 | CvDEPTH(cv) | |
1197 | B::CV cv | |
1198 | ||
1199 | B::AV | |
1200 | CvPADLIST(cv) | |
1201 | B::CV cv | |
1202 | ||
1203 | B::CV | |
1204 | CvOUTSIDE(cv) | |
1205 | B::CV cv | |
1206 | ||
1207 | void | |
1208 | CvXSUB(cv) | |
1209 | B::CV cv | |
1210 | CODE: | |
56431972 | 1211 | ST(0) = sv_2mortal(newSViv(PTR2IV(CvXSUB(cv)))); |
a8a597b2 MB |
1212 | |
1213 | ||
1214 | void | |
1215 | CvXSUBANY(cv) | |
1216 | B::CV cv | |
1217 | CODE: | |
1218 | ST(0) = sv_2mortal(newSViv(CvXSUBANY(cv).any_iv)); | |
1219 | ||
5cfd8ad4 VB |
1220 | MODULE = B PACKAGE = B::CV |
1221 | ||
6aaf4108 | 1222 | U16 |
5cfd8ad4 VB |
1223 | CvFLAGS(cv) |
1224 | B::CV cv | |
1225 | ||
de3f1649 JT |
1226 | MODULE = B PACKAGE = B::CV PREFIX = cv_ |
1227 | ||
1228 | B::SV | |
1229 | cv_const_sv(cv) | |
1230 | B::CV cv | |
1231 | ||
5cfd8ad4 | 1232 | |
a8a597b2 MB |
1233 | MODULE = B PACKAGE = B::HV PREFIX = Hv |
1234 | ||
1235 | STRLEN | |
1236 | HvFILL(hv) | |
1237 | B::HV hv | |
1238 | ||
1239 | STRLEN | |
1240 | HvMAX(hv) | |
1241 | B::HV hv | |
1242 | ||
1243 | I32 | |
1244 | HvKEYS(hv) | |
1245 | B::HV hv | |
1246 | ||
1247 | I32 | |
1248 | HvRITER(hv) | |
1249 | B::HV hv | |
1250 | ||
1251 | char * | |
1252 | HvNAME(hv) | |
1253 | B::HV hv | |
1254 | ||
1255 | B::PMOP | |
1256 | HvPMROOT(hv) | |
1257 | B::HV hv | |
1258 | ||
1259 | void | |
1260 | HvARRAY(hv) | |
1261 | B::HV hv | |
1262 | PPCODE: | |
1263 | if (HvKEYS(hv) > 0) { | |
1264 | SV *sv; | |
1265 | char *key; | |
1266 | I32 len; | |
1267 | (void)hv_iterinit(hv); | |
1268 | EXTEND(sp, HvKEYS(hv) * 2); | |
1269 | while (sv = hv_iternextsv(hv, &key, &len)) { | |
79cb57f6 | 1270 | PUSHs(newSVpvn(key, len)); |
cea2e8a9 | 1271 | PUSHs(make_sv_object(aTHX_ sv_newmortal(), sv)); |
a8a597b2 MB |
1272 | } |
1273 | } |