X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2Findirect.git;a=blobdiff_plain;f=indirect.xs;h=01b4a77ab3494923b1b1297b39a662f9c3029744;hp=9347467ea034cad3ae3aa75631cd5a2982ae74e9;hb=eb4b05d5ad6eec232107b4688e59685bc54f7a65;hpb=9e8840b03b5cfb27dc88d7e1e85533fc6bbef6b5 diff --git a/indirect.xs b/indirect.xs index 9347467..01b4a77 100644 --- a/indirect.xs +++ b/indirect.xs @@ -164,6 +164,7 @@ typedef struct { const char *pos; char *buf; STRLEN len, size; + line_t line; } indirect_op_info_t; #define PTABLE_NAME ptable @@ -368,8 +369,8 @@ STATIC SV *indirect_hint(pTHX) { /* ... op -> source position ............................................... */ -STATIC void indirect_map_store(pTHX_ const OP *o, const char *src, SV *sv) { -#define indirect_map_store(O, S, N) indirect_map_store(aTHX_ (O), (S), (N)) +STATIC void indirect_map_store(pTHX_ const OP *o, const char *src, SV *sv, line_t line) { +#define indirect_map_store(O, S, N, L) indirect_map_store(aTHX_ (O), (S), (N), (L)) indirect_op_info_t *oi; const char *s; STRLEN len; @@ -401,8 +402,9 @@ STATIC void indirect_map_store(pTHX_ const OP *o, const char *src, SV *sv) { oi->size = len; } Copy(s, oi->buf, len, char); - oi->len = len; - oi->pos = src; + oi->len = len; + oi->pos = src; + oi->line = line; } STATIC const indirect_op_info_t *indirect_map_fetch(pTHX_ const OP *o) { @@ -459,7 +461,8 @@ STATIC OP *indirect_ck_const(pTHX_ OP *o) { if (indirect_hint()) { SV *sv = cSVOPo_sv; if (SvPOK(sv) && (SvTYPE(sv) >= SVt_PV)) { - indirect_map_store(o, indirect_find(sv, PL_oldbufptr), sv); + const char *s = indirect_find(sv, PL_oldbufptr); + indirect_map_store(o, s, sv, CopLINE(&PL_compiling)); return o; } } @@ -524,7 +527,7 @@ STATIC OP *indirect_ck_rv2sv(pTHX_ OP *o) { } o = CALL_FPTR(indirect_old_ck_rv2sv)(aTHX_ o); - indirect_map_store(o, s, sv); + indirect_map_store(o, s, sv, CopLINE(&PL_compiling)); return o; } @@ -552,7 +555,7 @@ STATIC OP *indirect_ck_padany(pTHX_ OP *o) { while (s < t && isSPACE(*t)) --t; sv = sv_2mortal(newSVpvn("$", 1)); sv_catpvn_nomg(sv, s, t - s + 1); - indirect_map_store(o, s, sv); + indirect_map_store(o, s, sv, CopLINE(&PL_compiling)); return o; } } @@ -570,22 +573,25 @@ STATIC OP *indirect_ck_method(pTHX_ OP *o) { OP *op = cUNOPo->op_first; const indirect_op_info_t *oi = indirect_map_fetch(op); const char *s = NULL; + line_t line; SV *sv; if (oi && (s = oi->pos)) { - sv = sv_2mortal(newSVpvn(oi->buf, oi->len)); + sv = sv_2mortal(newSVpvn(oi->buf, oi->len)); + line = oi->line; /* Keep the old line so that we really point to the first */ } else { sv = cSVOPx_sv(op); if (!SvPOK(sv) || (SvTYPE(sv) < SVt_PV)) goto done; - sv = sv_mortalcopy(sv); - s = indirect_find(sv, PL_oldbufptr); + sv = sv_mortalcopy(sv); + s = indirect_find(sv, PL_oldbufptr); + line = CopLINE(&PL_compiling); } o = CALL_FPTR(indirect_old_ck_method)(aTHX_ o); /* o may now be a method_named */ - indirect_map_store(o, s, sv); + indirect_map_store(o, s, sv, line); return o; } @@ -646,8 +652,7 @@ STATIC OP *indirect_ck_entersub(pTHX_ OP *o) { goto done; if (moi->pos < ooi->pos) { - SV *file; - line_t line; + SV *file; dSP; ENTER; @@ -658,14 +663,13 @@ STATIC OP *indirect_ck_entersub(pTHX_ OP *o) { #else file = sv_mortalcopy(CopFILESV(&PL_compiling)); #endif - line = CopLINE(&PL_compiling); PUSHMARK(SP); EXTEND(SP, 4); mPUSHp(ooi->buf, ooi->len); mPUSHp(moi->buf, moi->len); PUSHs(file); - mPUSHu(line); + mPUSHu(moi->line); PUTBACK; call_sv(code, G_VOID);