Browse files

Fix importing constants from POSIX

POSIX has a special memory hack which conflicted with our symbol scraper.
  • Loading branch information...
1 parent 2fa43d9 commit 9dc204c5b6304403e338645685e0478d0490fde2 @sorear sorear committed Apr 26, 2010
Showing with 22 additions and 0 deletions.
  1. +12 −0 nt/export_constants.t
  2. +10 −0 perl5.pir
View
12 nt/export_constants.t
@@ -0,0 +1,12 @@
+# vim: ft=perl6
+
+plan(1);
+
+pir::load_bytecode('perl5.pbc');
+my $perl5 := pir::compreg__ps('perl5');
+
+my $module := $perl5.load_module('POSIX');
+
+my $exports := $perl5.get_exports($module);
+
+ok($exports<sub><ENOENT>() != 0, "Export can handle autoexpand constants");
View
10 perl5.pir
@@ -86,6 +86,16 @@ my $explist = sub {
for my $name (keys %Blizkost::ImportZone::) {
my $gref = \$Blizkost::ImportZone::{$name};
+ # Perl5 has a clever feature where a constant subroutine can be
+ # represented by putting a reference in the symbol table instead
+ # of an actual symbol table entry, saving memory and time. Pity
+ # we have to undo it.
+ if (ref($gref)) {
+ my $val = $$gref;
+ push @output, 'sub', $name, sub () { $val };
+ next;
+ }
+
my %things;
for my $type (qw/SCALAR ARRAY HASH IO/) {

0 comments on commit 9dc204c

Please sign in to comment.