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