Front page | perl.perl5.porters |
Postings from March 2008
rfc - Perl_ck_op_sanity
From:
Jim Cromie
Date:
March 13, 2008 14:29
Subject:
rfc - Perl_ck_op_sanity
Message ID:
47D99C98.5030907@gmail.com
folks,
It turns out that there is no Perl_ck_ routine that checks *all*
constructed ops.
ISTM that we should have one.
If nothing else, it gives us a place to put invariants,
and start to understand the science below the magic.
These asserts work (theres some overlap, but minimalism seems
counterproductive)
the last one feels clumsy - it special-cases mapstart vs grepstart;
is there something extra sneaky going on here (
What other invariants are possible/informative/worthwhile ?
diff -ruNp -X exclude-diffs ../bleadperl/op.c ckop/op.c
--- ../bleadperl/op.c 2008-03-10 15:43:52.000000000 -0600
+++ ckop/op.c 2008-03-13 14:52:07.000000000 -0600
@@ -6266,10 +6266,28 @@ Perl_newSVREF(pTHX_ OP *o)
/* Check routines. See the comments at the top of this file for details
* on when these are called */
+static
+void
+Perl_ck_opany(pTHX_ OP const * const o)
+{
+ int i = 0;
+
+ /* borrow one for now */
+ PERL_ARGS_ASSERT_CK_ANONCODE;
+ assert(o);
+
+ assert(o->op_type < OP_max);
+ assert(o->op_type || o->op_ppaddr == PL_ppaddr[0]);
+
+ assert(o->op_ppaddr);
+ assert(o->op_ppaddr == PL_ppaddr[o->op_type]
+ || o->op_type == 158);
+
+}
+
OP *
Perl_ck_anoncode(pTHX_ OP *o)
{
Ive trimmed the rest of the patch, but it looks basically like this,
repeated
OP *
Perl_ck_anoncode(pTHX_ OP *o)
{
PERL_ARGS_ASSERT_CK_ANONCODE;
+ Perl_ck_opany(aTHX_ o);
-
rfc - Perl_ck_op_sanity
by Jim Cromie