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