Re: more B::Concise stuff (PATCH - updated)

2004-05-14 Thread Rafael Garcia-Suarez
Jim Cromie wrote:
> Jim Cromie wrote:
> 
> > folks,
> >
> > attached patch has following adjustments to B::Concise and its tests.
> 
> 
> heres 2nd rev of that patch, now against 22802

Thanks, applied as change 22820. Time to play with it...


Re: more B::Concise stuff (PATCH - updated)

2004-05-10 Thread Jim Cromie
Jim Cromie wrote:

folks,

attached patch has following adjustments to B::Concise and its tests.


heres 2nd rev of that patch, now against 22802
- crossposted to perl-qa  for its test related aspects.
items 1-9 from prev post are all improved or solved

a. goto-bug squashed - reset_sequence() now resets $lastnext too.
formerly carrying 'state' from  one rendering to next.
b. showlex bug fixed - was due to signature change of B::Concise::fmt_line()

c. rendering-match-rex now tighter, esp wrt opcode args and [] vs () 
bracing.
   this may be more brittle - if pad-tmp-var numbering isnt consistent 
across platforms.
   (consider this a test - it wont be hard to re-broaden parts of regex 
to accomodate

d. 4 TODOs pass intentionally

   2 were myvar optimizations of 'my $a=()'
 I think done by RGS' 2nd varinit optimization (dunno patch # 
or title)
 i left as TODO to get ack / fact check / closure.

   2 are placeholders for {} and [] as args to B::Concise::compile,
 {} is good for splaying a stash, ex  \%::
 []  dunno yet. could do for BEGIN, END etc (already done)
   handler chains too.
e. package SPLAYING is un-touched.

One sticking point is err: sub has no ->START.
I think this happens on stub functions, so msg should maybe change 
accordingly.
This should do no harm, esp if you dont use it ...

NEW STUFF

Showlex.pm can now 'walk' a coderef, ala B::Concise.

(was formerly only a function name, looked up in the STASH).
Added 7 more tests to showlex.t, using compile(), walk_output().
also added -newlex option, which does a different PAD display:
it combines name and value on 1 line, 2x info density.
B::Showlex::compile(CODE(0x821a99c))
CODE(0x821a99c) Pad has 17 entries
0: SPECIAL #1 &PL_sv_undef
1: PVNV (0x821a960) "$self" = NULL (0x821a96c)
2: PVNV (0x821a948) "%props" = HV (0x821a93c) HASH
3: SPECIAL #1 &PL_sv_undef = NULL (0x821a954)
4: SPECIAL #1 &PL_sv_undef = NULL (0x821a930)
5: PVNV (0x821a918) "$total" = NULL (0x821a924)
6: PVNV (0x821a900) "@fib" = AV (0x821a8f4) undef
7: SPECIAL #1 &PL_sv_undef = NULL (0x821a8dc)
8: PVNV (0x821a8c4) "$i" = NULL (0x821a8d0)
9: SPECIAL #1 &PL_sv_undef = NULL (0x821a8a0)
10: SPECIAL #1 &PL_sv_undef = NULL (0x821a888)
11: SPECIAL #1 &PL_sv_undef = NULL (0x821a870)
12: SPECIAL #1 &PL_sv_undef = NULL (0x821a864)
13: PVNV (0x821a84c) "$i" = NULL (0x821a858)
14: SPECIAL #1 &PL_sv_undef = PVNV (0x821a828) undef
15: SPECIAL #1 &PL_sv_undef = PVNV (0x821a81c) undef
16: SPECIAL #1 &PL_sv_undef = NULL (0x821a810)
Since theres no back compat issues with -newlex, Im open to suggestions
on how info can be cleaner / more user-friendly
1. replace most SPECIAL #1 undefs with "PadTmp$i" where $i is col 1 above
   these would correlate with t3 as represented in Concise output. (or 
is this just wrong?)

2. suppress ' = NULL (0x)'   it provides almost no info.
   most porters seem to use Devel::Peek when they want this kind of info,
   so showlex can specialize towards more overview.
   A good option - suppress normal chatter - print when unusual
3. get it to display [$i:start-ln,end-ln] where appropriate.

4. use Getopt::Std.  may be issues vs O.pm conventions.

ALSO NOTE:   

Showlex output (not -newlex ) for coderefs differs a bit from comppadlist.
There were no tests of comppadlist output, so I dont know whether this 
diff is expected,
or its something I broke / changed.

diffs show up in lex-values array - 0 displays as AV, not SPECIAL
AVs now have trailing 'undef' when theyve got no value.
HVs have 'HASH', put there by ?? B::SV::terse, which gets it from concise_sv
[EMAIL PROTECTED] latest]$ ./perl ext/B/t/showlex.t 9  # any arg forces verbose

...
Pad of lexical values for comppadlist has 3 entries
0: SPECIAL #1 &PL_sv_undef
1: NULL (0x8180f68)
2: NULL (0x818efd8)
vs

Pad of lexical values for CODE(0x821aa54) has 4 entries
0: AV (0x821aa0c) undef
1: NULL (0x821aa24)
2: AV (0x821a9f4) undef undef added by concise_sv tweak
3: HV (0x821a9dc) HASH
TEST GENERATION support

This optree regression testing framework needs tests in order to find
bugs.  To that end, OptreeCheck has support for developing new tests,
according to the following model:
1. write a set of sample code into a single file, one per
   paragraph.  f_map and f_sort in ext/B/t/ are examples.
2. run OptreeCheck as a program on the file

  ./perl -Ilib ext/B/t/OptreeCheck.pm -w ext/B/t/f_map
  ./perl -Ilib ext/B/t/OptreeCheck.pm -w ext/B/t/f_sort
  As prog, it reads the samples of code from the file, runs each to 
generate a reference
  rendering, folds this rendering into an optreeCheck() statement,
  and prints it to stdout.

3. run the output file as above, redirect to files, then rerun as a test on
   same build (for sanity check), and on thread-opposite build.  With
   editor in 1 window, and cmd in other, its fairly easy to cut-paste
   the gots into the expects, easier than running step 2 on both
   builds then trying to sdiff them together.
4. my reason