Fixed (changed) test 46 in B::C

13 views
Skip to first unread message

Reini Urban

unread,
Oct 19, 2011, 12:30:54 PM10/19/11
to J. Nick Koston, perl-c...@googlegroups.com
Hi Nick,

See http://code.google.com/p/perl-compiler/source/detail?r=1206
You wanted to test for the Exporter STASH to appear in the *main:: STASH

You did:
use Exporter; if (exists $main::{"Exporter::"}) { print "ok"; }
which passed in perl but failed in perlcc

The test should be
use Exporter; print q(ok) if defined *main::Exporter::{HASH};

In your test $main:: is autovivified to main:: at run-time only, which
is optimized away at compile-time.
We could use such a behaviour as test if we run compiled or not, but
it looks dirty.
--
Reini Urban
http://cpanel.net/   http://www.perl-compiler.org/

J. Nick Koston

unread,
Oct 19, 2011, 8:13:20 PM10/19/11
to Reini Urban, perl-c...@googlegroups.com
Hi Reini,

I think we need something like this

'use Exporter; use Data::Dumper (); print Data::Dumper::Dumper(\%main::);'

to work the same as it does in compiled and non-compiled perl. I'm concerned with code that checks for these symbols and loads code dynamically.

-Nick

Reini Urban

unread,
Oct 20, 2011, 10:10:01 AM10/20/11
to perl-c...@googlegroups.com
On Wed, Oct 19, 2011 at 7:13 PM, J. Nick Koston <ni...@cpanel.net> wrote:
> I think we need something like this
>
> 'use Exporter; use Data::Dumper (); print Data::Dumper::Dumper(\%main::);'
>
> to work the same as it does in compiled and non-compiled perl.   I'm concerned with code that checks for these symbols and loads code dynamically.

Almost works:

$ pb -e'use Exporter; use Data::Dumper (); CHECK{ print
Data::Dumper::Dumper(\%main::) }'
$VAR1 = {
'version::' => *{'::version::'},
'/' => *{'::/'},
'stderr' => *::stderr,
'SIG' => *::SIG,
',' => *{'::,'},
'utf8::' => *{'::utf8::'},
'"' => *{'::"'},
're::' => *{'::re::'},
'DynaLoader::' => *{'::DynaLoader::'},
'mro::' => *{'::mro::'},
'strict::' => *{'::strict::'},
'Cwd::' => *{'::Cwd::'},
'stdout' => *::stdout,
'' => *{'::'},
'Regexp::' => *{'::Regexp::'},
'_</usr/local/lib/perl5/5.14.2/darwin-thread-debug/auto/Data/Dumper/Dumper.bundle'
=> *{'::_</usr/local/lib/perl5/5.14.2/darwin-thread-debug/auto/Data/Dumper/Dumper.bundle'},
'UNIVERSAL::' => *{'::UNIVERSAL::'},
'overload::' => *{'::overload::'},
'$' => *{'::$'},
'File::' => *{'::File::'},
'E_TRIE_MAXBUF' => *{'::E_TRIE_MAXBUF'},
'Dos::' => *{'::Dos::'},
'Data::' => *{'::Data::'},
'_<perlmain.c' => *{'::_<perlmain.c'},
'_<universal.c' => *{'::_<universal.c'},
'BEGIN' => *::BEGIN,
'!' => *{'::!'},
'IO::' => *{'::IO::'},
'' => *{'::'},
'' => *{'::'},
'_' => *::_,
'Exporter::' => *{'::Exporter::'},
'Internals::' => *{'::Internals::'},
'STDIN' => *::STDIN,
'Config::' => *{'::Config::'},
'warnings::' => *{'::warnings::'},
'DB::' => *{'::DB::'},
'_<perl.c' => *{'::_<perl.c'},
'EPOC::' => *{'::EPOC::'},
'_</usr/local/lib/perl5/5.14.2/warnings.pm' =>
*{'::_</usr/local/lib/perl5/5.14.2/warnings.pm'},
'_<mro.c' => *{'::_<mro.c'},
'2' => *{'::2'},
'_<Cwd.c' => *{'::_<Cwd.c'},
'blib::' => *{'::blib::'},
'1' => *{'::1'},
'ARNING_BITS' => *{'::ARNING_BITS'},
'CORE::' => *{'::CORE::'},
'_<DynaLoader.c' => *{'::_<DynaLoader.c'},
'stdin' => *::stdin,
'ARGV' => *::ARGV,
'INC' => *::INC,
'_<-e' => *{'::_<-e'},
'Scalar::' => *{'::Scalar::'},
'ENV' => *::ENV,
'vars::' => *{'::vars::'},
'XSLoader::' => *{'::XSLoader::'},
'_<perlio.c' => *{'::_<perlio.c'},
'B::' => *{'::B::'},
'main::' => *{'::main::'},
'Carp::' => *{'::Carp::'},
'VMS::' => *{'::VMS::'},
'Win32::' => *{'::Win32::'},
'PerlIO::' => *{'::PerlIO::'},
'0' => *{'::0'},
' => *{':'},
'@' => *{'::@'},
'STDOUT' => *::STDOUT,
']' => *{'::]'},
'3' => *{'::3'},
'_</usr/local/lib/perl5/5.14.2/darwin-thread-debug/auto/Cwd/Cwd.bundle'
=> *{'::_</usr/local/lib/perl5/5.14.2/darwin-thread-debug/auto/Cwd/Cwd.bundle'},
'' => *{'::'},
'threads::' => *{'::threads::'},
'_<Dumper.c' => *{'::_<Dumper.c'},
'bytes::' => *{'::bytes::'},
'STDERR' => *::STDERR
};

$ pb script/perlcc -r -e'use Exporter; use Data::Dumper (); print
Data::Dumper::Dumper(\%main::)'
$VAR1 = {
'stdin' => *::stdin,
'' => *{'::'},
'INC' => *::INC,
'3' => *{'::3'},
']' => *{'::]'},
'SIG' => *::SIG,
'' => *{'::/H'},
'' => *{'::/'},
'2' => *{'::2'},
'"' => *{'::"'},
'STDERR' => *::STDERR,
'0' => *{'::0'},
';' => *{'::;'},
'!' => *{'::!'}
};

What other symbols to we need compiled?
We leave out intentionally the symbols beginning with ! ; _< and so on.

Reini Urban

unread,
Oct 20, 2011, 10:15:14 AM10/20/11
to perl-c...@googlegroups.com


I see. I need to add all the stashes.
'bytes::' => *{'::bytes::'}, and so on.
Should be easy to add.
--
Reini

J. Nick Koston

unread,
Oct 20, 2011, 10:17:42 AM10/20/11
to perl-c...@googlegroups.com
I think we just need all the package references i.e.:

>> 'Cwd::' => *{'::Cwd::'},
>

>> 'Config::' => *{'::Config::'},
>

>

> --
> Unsubscribe via mail to perl-compile...@googlegroups.com
> Options: http://groups.google.com/group/perl-compiler?hl=en
>

Reply all
Reply to author
Forward
0 new messages