-
Notifications
You must be signed in to change notification settings - Fork 0
/
crap.xs
61 lines (50 loc) · 1.32 KB
/
crap.xs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#define PERL_NO_GET_CONTEXT 1
#ifdef WIN32
# define NO_XSLOCKS
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
OP*
MY_pp_entereval_compile_only(pTHX)
{
dSP;
OP* orig_next = PL_op->op_next;
OP* retop = PL_ppaddr[OP_ENTEREVAL](aTHX);
if ( retop != orig_next ) {
/* code compiled! give them a true value */
PL_ppaddr[OP_LEAVEEVAL](aTHX);
SETs(&PL_sv_yes);
}
else {
/* should never happen... failing to compile should jump over this op */
SETs(&PL_sv_no);
}
RETURN;
}
static OP *
S_ck_replace_entersub_with_myeval(pTHX_ OP *entersubop, GV *namegv, SV *cv)
{
OP* new_op;
OP* pushop;
OP* realop;
pushop = cUNOPx(entersubop)->op_first;
if (!pushop->op_sibling)
pushop = cUNOPx(pushop)->op_first;
realop = pushop->op_sibling;
if (!realop || !realop->op_sibling)
return entersubop;
pushop->op_sibling = realop->op_sibling;
realop->op_sibling = NULL;
op_free(entersubop);
new_op = newUNOP(OP_ENTEREVAL, 0, realop);
new_op->op_ppaddr = MY_pp_entereval_compile_only;
return new_op;
}
MODULE = eval::crap PACKAGE = eval::crap
PROTOTYPES: DISABLE
BOOT:
{
CV * const cv = get_cvn_flags("eval::crap::compile", 19, 1);
cv_set_call_checker(cv, S_ck_replace_entersub_with_myeval, &PL_sv_undef);
}