develooper Front page | perl.perl5.porters | Postings from August 2010

Re: [PATCH] Support B::Generate and B::C

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
August 30, 2010 02:54
Subject:
Re: [PATCH] Support B::Generate and B::C
Message ID:
20100830095424.GF48531@plum.flirble.org
On Mon, Aug 30, 2010 at 02:30:16AM -0600, Jim Cromie wrote:

> > You patch has no tests. For the documentation for fold_constants I see:
> >
> >
> attached is a patch adding fold-constant tests;
> number arithmetic fold,
> string catenation fold,
> lc* & uc* folds
> various string compare conditional folds
> boolean constant conditional fold,
> mixed str-cat . arithmetic fold, with () for forced precendence.
> and TODO version without the ()

Thanks, this is useful, but this doesn't actually test that fold_constants()
folds constants. If the core is refactored so that particular optree
generation activities happen at different times, the above test would still
pass, but anything relying on the behaviour of fold_constants() would break.

What would be needed for that is something like:

0: Apply Reini's patch locally
1: In (say) XS::APITest create 3 ops, say

                ADD
               /   \
          CONST     CONST

   [linked correctly as the core's parser would at this point. I think that
    this means op_first and op_last, not op_next]

2: Call fold_constants
3: Verify that the returned OP is just a CONST op, with the correct value.

I suspect that B is useful here.

> > So does that mean that it's valid in future for this function to stick to
> > *that* documentation, and only fold constants?
> >
> > As I discovered by accident last night, it also
> >
> > b: creates targets for ops that need targets but don't yet have them
> >
> > and I see from looking at the code it also
> >
> > c: propagates scalar context for ops that return a scalar
> 
> d: runs LINKLIST()
> > e: implements 'use integer';
> >
> >
> can you suggest perl statements that trigger these particular cases ?

As above. *If* the documented behaviour of fold_constants is that it does
quite a lot more than folding constants, then all of the above should be
tested something like I suggested above

1: create a simple op structure
2: test that pointers/values aren't (yet) set.
3: call fold_constants
4: test that pointers/values are not set.


Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About