rurban / perl-compiler

B::C - Moved over from googlecode
https://code.google.com/p/perl-compiler/
Other
64 stars 23 forks source link

PVFM not correctly compiled (format) #300

Open atoomic opened 9 years ago

atoomic commented 9 years ago

This is similar to issue #290 PVFM are not saved

> cat test.pl
    format STDERR = 
.
    my $stdout = *STDOUT{IO};
    my $stderr = *STDERR{FORMAT};
    print ref($stdout).' || '.ref($stderr)."\n";
> perl test.pl
IO::File || FORMAT
> perlcc -r test.pl
IO::File ||

When dumping the SVs on compiled and uncompiled code. we can notice that the PVFM is null once compiled Add this dumy patch

    eval q/use Devel::Peek/;
    Dump($stdout);
    print STDERR "="x20, "\n";
    Dump($stderr);
# UNCOMPILED
SV = IV(0x9411960) at 0x9411964
  REFCNT = 1
  FLAGS = (ROK)
  RV = 0x941139c
  SV = PVIO(0x9412dec) at 0x941139c
    REFCNT = 3
    FLAGS = (OBJECT)
    STASH = 0x9411054   "IO::File"
    IFP = 0x940d428
    OFP = 0x940d428
    DIRP = 0x0
    LINES = 0
    PAGE = 0
    PAGE_LEN = 60
    LINES_LEFT = 0
    TOP_GV = 0x0
    FMT_GV = 0x0
    BOTTOM_GV = 0x0
    TYPE = '>'
    FLAGS = 0x0
====================
SV = IV(0x941199c) at 0x94119a0
  REFCNT = 1
  FLAGS = (ROK)
  RV = 0x9411978
  SV = PVFM(0x941a078) at 0x9411978
    REFCNT = 2
    FLAGS = ()
    COMP_STASH = 0x0
    START = 0x941a218 ===> 1
    ROOT = 0x941a1f8
    GVGV::GV = 0x94113d8    "main" :: "STDERR"
    FILE = "test.pl"
    DEPTH = 0
    FLAGS = 0x0
    OUTSIDE_SEQ = 4294967247
    PADLIST = 0x941a0b8
    PADNAME = 0x941a0e8(0x941a100) PAD = 0x941198c(0x941a0d0)
    OUTSIDE = 0x9400468 (MAIN)
# COMPILED
SV = IV(0x804e44c) at 0x804e450
  REFCNT = 1
  FLAGS = (ROK)
  RV = 0x804e374
  SV = PVIO(0x804e1e0) at 0x804e374
    REFCNT = 3
    FLAGS = (OBJECT)
    STASH = 0x97e01b0   "IO::File"
    IFP = 0x97dc460
    OFP = 0x97dc460
    DIRP = 0x0
    LINES = 0
    PAGE = 0
    PAGE_LEN = 60
    LINES_LEFT = 0
    TOP_GV = 0x0
    FMT_GV = 0x0
    BOTTOM_GV = 0x0
    TYPE = '>'
    FLAGS = 0x0
====================
SV = NULL(0x0) at 0x804e464
  REFCNT = 1
  FLAGS = ()
toddr commented 9 years ago

This is another example of the problem I think:

sub IO::Handle::turn {};
UNIVERSAL::can(*STDOUT, "turn") and print "ok 1 - globs with IOs can";
UNIVERSAL::can(\*STDOUT, "turn") and print "ok 2 - globrefs with IOs can\n";
UNIVERSAL::can("STDOUT", "turn") and print "ok 3 - IO barewords can\n";"

Under perl.

$>perl -e 'sub IO::Handle::turn {}; UNIVERSAL::can(*STDOUT, "turn") and print "ok 1 - globs with IOs can\n"; UNIVERSAL::can(\*STDOUT, "turn") and print "ok 2 - globrefs with IOs can\n"; UNIVERSAL::can("STDOUT", "turn") and print "ok 3 - IO barewords can\n";'     
ok 1 - globs with IOs can
ok 2 - globrefs with IOs can
ok 3 - IO barewords can

No output under perlcc

$>perlcc -r -e 'sub IO::Handle::turn {}; UNIVERSAL::can(*STDOUT, "turn") and print "ok 1 - globs with IOs can\n"; UNIVERSAL::can(\*STDOUT, "turn") and print "ok 2 - globrefs with IOs can\n"; UNIVERSAL::can("STDOUT", "turn") and print "ok 3 - IO barewords can\n";'
atoomic commented 9 years ago

testc.sh 300