line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* vi: set ft=c : */ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
/* Wrappers between OP * and B::OP-blessed SVs */ |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#define newSVop(o) S_newSVop(aTHX_ o) |
6
|
0
|
|
|
|
|
|
static SV *S_newSVop(pTHX_ OP *o) |
7
|
|
|
|
|
|
|
{ |
8
|
0
|
|
|
|
|
|
SV *ret = newSV(0); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
const char *opclassname; |
11
|
0
|
|
|
|
|
|
switch(op_class(o)) { |
12
|
|
|
|
|
|
|
case OPclass_BASEOP: opclassname = "B::OP"; break; |
13
|
0
|
|
|
|
|
|
case OPclass_UNOP: opclassname = "B::UNOP"; break; |
14
|
0
|
|
|
|
|
|
case OPclass_BINOP: opclassname = "B::BINOP"; break; |
15
|
0
|
|
|
|
|
|
case OPclass_LOGOP: opclassname = "B::LOGOP"; break; |
16
|
0
|
|
|
|
|
|
case OPclass_LISTOP: opclassname = "B::LISTOP"; break; |
17
|
0
|
|
|
|
|
|
case OPclass_PMOP: opclassname = "B::PMOP"; break; |
18
|
0
|
|
|
|
|
|
case OPclass_SVOP: opclassname = "B::SVOP"; break; |
19
|
0
|
|
|
|
|
|
case OPclass_PADOP: opclassname = "B::PADOP"; break; |
20
|
0
|
|
|
|
|
|
case OPclass_PVOP: opclassname = "B::PVOP"; break; |
21
|
0
|
|
|
|
|
|
case OPclass_LOOP: opclassname = "B::LOOP"; break; |
22
|
0
|
|
|
|
|
|
case OPclass_COP: opclassname = "B::COP"; break; |
23
|
0
|
|
|
|
|
|
case OPclass_METHOP: opclassname = "B::METHOP"; break; |
24
|
0
|
|
|
|
|
|
case OPclass_UNOP_AUX: opclassname = "B::UNOP_AUX"; break; |
25
|
|
|
|
|
|
|
default: |
26
|
0
|
|
|
|
|
|
croak("TODO: handle opclass=%d\n", op_class(o)); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
sv_setiv(newSVrv(ret, opclassname), PTR2IV(o)); |
30
|
0
|
|
|
|
|
|
return ret; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#define SvOPo(sv) S_SvOPo(aTHX_ sv) |
34
|
0
|
|
|
|
|
|
static OP *S_SvOPo(pTHX_ SV *sv) |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
0
|
|
|
|
|
if(!SvOK(sv)) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
croak("Expected a B::OP instance, found "); |
38
|
0
|
0
|
|
|
|
|
if(!SvROK(sv) || !sv_derived_from(sv, "B::OP")) |
|
|
0
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
croak("Expected a B::OP instance, found %" SVf, SVfARG(sv)); |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
return NUM2PTR(OP *, SvIV(SvRV(sv))); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#define maySvOPo(sv) (sv && SvOK(sv) ? SvOPo(sv) : NULL) |