[svn:parrot] r36792 - in trunk: config/gen include/parrot lib/Parrot/Pmc2c

allison at svn.parrot.org allison at svn.parrot.org
Mon Feb 16 08:49:33 UTC 2009


Author: allison
Date: Mon Feb 16 08:49:33 2009
New Revision: 36792
URL: https://trac.parrot.org/parrot/changeset/36792

Log:
[install] Change generated perl constants to a loadable module of 'use
constant' statements, instead of a fragmented hash declaration. This
allows PCCMETHOD.pm to be used from an installed Parrot. Also resolves
RT #42286.

Modified:
   trunk/config/gen/parrot_include.pm
   trunk/include/parrot/enums.h
   trunk/lib/Parrot/Pmc2c/   (props changed)
   trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm

Modified: trunk/config/gen/parrot_include.pm
==============================================================================
--- trunk/config/gen/parrot_include.pm	Mon Feb 16 08:22:28 2009	(r36791)
+++ trunk/config/gen/parrot_include.pm	Mon Feb 16 08:49:33 2009	(r36792)
@@ -57,9 +57,8 @@
     map ".macro_const $_->[0]\t$_->[1]", @_;
 }
 
-# refactor to generate 'use constant' statements, RT#42286
 sub const_to_perl {
-    map "$_->[0] => $_->[1],", @_;
+    map "use constant $_->[0] => $_->[1];", @_;
 }
 
 sub transform_name {
@@ -195,14 +194,18 @@
             my @defs = perform_directive $d;
             for my $target ( @{ $d->{files} } ) {
                 $verbose and print "$target ";
-                my $gen = join "\n",
-                    ( $target =~ /\.pl$/ ? \&const_to_perl : \&const_to_parrot )->(@defs);
+                my $gen;
+                if ( $target =~ /\.pm$/ ) {
+                    $gen = join "\n", &const_to_perl(@defs);
+                    $gen .= "\n1;";
+                }
+                else {
+                    $gen = join "\n", &const_to_parrot(@defs);
+                }
                 $conf->append_configure_log(qq{$self->{destdir}/$target});
                 my $target_tmp = "$target.tmp";
                 open my $out, '>', $target_tmp or die "Can't open $target_tmp: $!\n";
 
-                # refactor to include package declarations and Export
-                # declarations for generated Perl constant modules, RT#42286
                 print $out <<"EOF";
 # DO NOT EDIT THIS FILE.
 #

Modified: trunk/include/parrot/enums.h
==============================================================================
--- trunk/include/parrot/enums.h	Mon Feb 16 08:22:28 2009	(r36791)
+++ trunk/include/parrot/enums.h	Mon Feb 16 08:49:33 2009	(r36792)
@@ -42,7 +42,7 @@
 
 /* &end_gen */
 
-/* &gen_from_enum(call_bits.pasm lib/Parrot/Pmc2c/PCCMETHOD_BITS.pl) */
+/* &gen_from_enum(call_bits.pasm lib/Parrot/Pmc2c/PCCMETHOD_BITS.pm) */
 typedef enum {
     /* 4 low bits are argument types */
     PARROT_ARG_INTVAL           = 0x000,  /* 0 */

Modified: trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm
==============================================================================
--- trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm	Mon Feb 16 08:22:28 2009	(r36791)
+++ trunk/lib/Parrot/Pmc2c/PCCMETHOD.pm	Mon Feb 16 08:49:33 2009	(r36792)
@@ -5,6 +5,7 @@
 use strict;
 use warnings;
 use Carp qw(longmess croak);
+use Parrot::Pmc2c::PCCMETHOD_BITS;
 
 =head1 NAME
 
@@ -71,20 +72,6 @@
 use constant REGNO_STR => 2;
 use constant REGNO_PMC => 3;
 
-# refactor to a simple module import, RT#42286
-BEGIN {
-    my $bits   = 'Parrot/Pmc2c/PCCMETHOD_BITS.pl';
-    my %consts = do $bits;
-    unless (%consts) {
-        die $@ if $@;
-        die "$bits: $!";
-    }
-    require constant;
-    while ( my ( $k, $v ) = each %consts ) {
-        constant->import( $k, $v );
-    }
-}
-
 =head3
     regtype to argtype conversion hash
 =cut


More information about the parrot-commits mailing list