diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-01-05 22:33:12 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-01-05 22:33:12 +0000 |
commit | d2f13c598f9812cd520097e22d819d1b9f7b0cb6 (patch) | |
tree | 51c2739d4fe37c20fc90e087816461a35cf48e5a | |
parent | 62a1a1efb41483ae8589f3158be0ce9a1c21e8e2 (diff) | |
download | perl-d2f13c598f9812cd520097e22d819d1b9f7b0cb6.tar.gz |
Make REGEXP a type distinct from SV. (Much like AV, CV, GV, HV).
p4raw-id: //depot/perl@32861
-rw-r--r-- | perl.h | 2 | ||||
-rw-r--r-- | pp_ctl.c | 8 | ||||
-rw-r--r-- | pp_hot.c | 2 | ||||
-rw-r--r-- | regcomp.c | 6 | ||||
-rw-r--r-- | regexec.c | 10 | ||||
-rw-r--r-- | sv.c | 8 | ||||
-rw-r--r-- | sv.h | 5 | ||||
-rw-r--r-- | util.c | 2 |
8 files changed, 24 insertions, 19 deletions
@@ -2353,7 +2353,7 @@ typedef struct av AV; typedef struct hv HV; typedef struct cv CV; typedef struct regexp ORANGE; /* This is the body structure. */ -typedef SV REGEXP; +typedef struct p5rx REGEXP; typedef struct gp GP; typedef struct gv GV; typedef struct io IO; @@ -117,7 +117,7 @@ PP(pp_regcomp) if (SvROK(tmpstr)) { SV * const sv = SvRV(tmpstr); if (SvTYPE(sv) == SVt_REGEXP) - re = sv; + re = (REGEXP*) sv; } if (re) { re = reg_temp_copy(re); @@ -3914,11 +3914,11 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) # define SM_REGEX ( \ (SvROK(d) && (SvTYPE(This = SvRV(d)) == SVt_REGEXP) \ - && (this_regex = This) \ + && (this_regex = (REGEXP*) This) \ && (Other = e)) \ || \ (SvROK(e) && (SvTYPE(This = SvRV(e)) == SVt_REGEXP) \ - && (this_regex = This) \ + && (this_regex = (REGEXP*) This) \ && (Other = d)) ) @@ -3927,7 +3927,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) # define SM_OTHER_REGEX (SvROK(Other) \ && (SvTYPE(SvRV(Other)) == SVt_REGEXP) \ - && (other_regex = SvRV(Other))) + && (other_regex = (REGEXP*) SvRV(Other))) # define SM_SEEN_THIS(sv) hv_exists_ent(seen_this, \ @@ -1199,7 +1199,7 @@ PP(pp_qr) /* This RV is about to own a reference to the regexp. (In addition to the reference already owned by the PMOP. */ ReREFCNT_inc(rx); - SvRV_set(rv, rx); + SvRV_set(rv, (SV*) rx); SvROK_on(rv); if (pkg) { @@ -4264,7 +4264,7 @@ redo_first_pass: /* Allocate space and zero-initialize. Note, the two step process of zeroing when in debug mode, thus anything assigned has to happen after that */ - rx = newSV_type(SVt_REGEXP); + rx = (REGEXP*) newSV_type(SVt_REGEXP); r = (struct regexp*)SvANY(rx); Newxc(ri, sizeof(regexp_internal) + (unsigned)RExC_size * sizeof(regnode), char, regexp_internal); @@ -4294,7 +4294,7 @@ redo_first_pass: + (sizeof(STD_PAT_MODS) - 1) + (sizeof("(?:)") - 1); - p = sv_grow(rx, wraplen + 1); + p = sv_grow((SV *)rx, wraplen + 1); SvCUR_set(rx, wraplen); SvPOK_on(rx); SvFLAGS(rx) |= SvUTF8(pattern); @@ -9201,7 +9201,7 @@ Perl_pregfree2(pTHX_ REGEXP *rx) REGEXP * Perl_reg_temp_copy (pTHX_ REGEXP *rx) { - REGEXP *ret_x = newSV_type(SVt_REGEXP); + REGEXP *ret_x = (REGEXP*) newSV_type(SVt_REGEXP); struct regexp *ret = (struct regexp *)SvANY(ret_x); struct regexp *const r = (struct regexp *)SvANY(rx); register const I32 npar = r->nparens+1; @@ -3633,7 +3633,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) #define ST st->u.eval { SV *ret; - SV *re_sv; + REGEXP *re_sv; regexp *re; regexp_internal *rei; regnode *startpoint; @@ -3720,13 +3720,13 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) SV *const sv = SvRV(ret); if (SvTYPE(sv) == SVt_REGEXP) { - rx = sv; + rx = (REGEXP*) sv; } else if (SvSMAGICAL(sv)) { mg = mg_find(sv, PERL_MAGIC_qr); assert(mg); } } else if (SvTYPE(ret) == SVt_REGEXP) { - rx = ret; + rx = (REGEXP*) ret; } else if (SvSMAGICAL(ret)) { if (SvGMAGICAL(ret)) { /* I don't believe that there is ever qr magic @@ -3745,7 +3745,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) } if (mg) { - rx = mg->mg_obj; /*XXX:dmq*/ + rx = (REGEXP *) mg->mg_obj; /*XXX:dmq*/ assert(rx); } if (rx) { @@ -3774,7 +3774,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog) /* This isn't a first class regexp. Instead, it's caching a regexp onto an existing, Perl visible scalar. */ - sv_magic(ret, rx, PERL_MAGIC_qr, 0, 0); + sv_magic(ret, (SV*) rx, PERL_MAGIC_qr, 0, 0); } PL_regsize = osize; } @@ -5240,7 +5240,7 @@ Perl_sv_clear(pTHX_ register SV *sv) goto freescalar; case SVt_REGEXP: /* FIXME for plugins */ - pregfree2(sv); + pregfree2((REGEXP*) sv); goto freescalar; case SVt_PVCV: case SVt_PVFM: @@ -10251,7 +10251,7 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param) break; case SVt_REGEXP: /* FIXME for plugins */ - re_dup_guts(sstr, dstr, param); + re_dup_guts((REGEXP*) sstr, (REGEXP*) dstr, param); break; case SVt_PVLV: /* XXX LvTARGOFF sometimes holds PMOP* when DEBUGGING */ @@ -11247,9 +11247,9 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, pointer inside an IV hack? */ SV * const sv = SvREPADTMP(regex) - ? sv_dup_inc(regex, param) + ? sv_dup_inc((SV*) regex, param) : SvREFCNT_inc( - newSViv(PTR2IV(sv_dup_inc(INT2PTR(REGEXP *, SvIVX(regex)), param)))) + newSViv(PTR2IV(sv_dup_inc(INT2PTR(SV *, SvIVX(regex)), param)))) ; if (SvFLAGS(regex) & SVf_BREAK) SvFLAGS(sv) |= SVf_BREAK; /* unrefcnted PL_curpm */ @@ -150,6 +150,11 @@ struct io { _SV_HEAD_UNION; }; +struct p5rx { + _SV_HEAD(struct regexp*); /* pointer to regexp body */ + _SV_HEAD_UNION; +}; + #undef _SV_HEAD #undef _SV_HEAD_UNION /* ensure no pollution */ @@ -5921,7 +5921,7 @@ Perl_get_re_arg(pTHX_ SV *sv) { (tmpsv = (SV*)SvRV(sv)) && /* assign deliberate */ SvTYPE(tmpsv) == SVt_REGEXP) { - return tmpsv; + return (REGEXP*) tmpsv; } } |