# New Ticket Created by Alberto Manuel Brand�o Sim�es
# Please include the string: [perl #15345]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=15345 >
A simple way to generate assemble.pl constants initializaiton using
include/parrot/pmc.h
In attach, diff file and config/gen/enum.pl.
If accepted, it is needed to call enum.pl from somewhere (at the root
parrot distribution).
Regards,
Alberto
--
Alberto Manuel B. Simoes
Departamento de Inform�tica - Universidade do Minho
http://alfarrabio.di.uminho.pt/~albie - http://numexp.sf.net
-- attachment 1 ------------------------------------------------------
url: http://rt.perl.org/rt2/attach/30988/25974/8eaf7c/diff_file2
-- attachment 2 ------------------------------------------------------
url: http://rt.perl.org/rt2/attach/30988/25975/877c67/enum.pl
Index: assemble.pl
===================================================================
RCS file: /cvs/public/parrot/assemble.pl,v
retrieving revision 1.82
diff -u -r1.82 assemble.pl
--- assemble.pl 18 Jul 2002 02:13:27 -0000 1.82
+++ assemble.pl 22 Jul 2002 16:44:34 -0000
@@ -127,6 +127,7 @@
# XXX Must be generated from the enum in include/parrot/pmc.h
#
bless $self,$class;
+ # Constants initilization
$self->{constants}{Array} = 0;
$self->{constants}{PerlUndef} = 1;
$self->{constants}{PerlInt} = 2;
#! perl
# read that enum from 'include/parrot/pmc.h'
open F, "<include/parrot/pmc.h" or die "Cannot open file 'include/parrot/pmc.h'";
my @list;
while(<F>) {
chomp;
push @list, $1 if (m!enum_class_(\w+),!);
}
close F;
# Generate the string...
my $string = "";
my $i = 0;
for (@list) {
$string.= " \$self->{constants}{$_} = $i;\n";
$i ++;
}
# open and read 'assemble.pl'
open I, "<assemble.pl" or die "Cannot open file 'assemble.pl'";
open O, ">assemble.pl_" or die "Cannot open file 'assemble.pl_' for writting";
while(<I>) {
print O;
if (m!# Constants initilization!) {
while(<I>) {
last if m!\$self;!;
}
print O $string;
print O " \$self;\n";
}
}
close O;
close I;
# Move assemble.pl_ to assemble.pl
# if anybody knows a simple way, go ahead
open I, "<assemble.pl_" or die "Cannot open file 'assemble.pl_'";
open O, ">assemble.pl" or die "Cannot open file 'assemble.pl' for writting";
while(<I>) { print O }
close O;
close I;
unlink "assemble.pl_";