# New Ticket Created by Leopold Toetsch # Please include the string: [perl #16297] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=16297 >
Hi, attached patch gets rid of the propably hand crafted PMC types list by using lib/Parrot/PMC.pm. The %pmc_types where created in lowercase before, but, as there are no current users of %pmc_types, this should not be a problem. Please apply. leo -- attachment 1 ------------------------------------------------------ url: http://rt.perl.org/rt2/attach/34377/28106/8ee39e/assemble.pl.diff -- attachment 2 ------------------------------------------------------ url: http://rt.perl.org/rt2/attach/34377/28107/bbf71f/pmc_pm.pl.diff
--- assemble.pl Sun Aug 18 08:54:22 2002 +++ /home/lt/src/parrot-007/assemble.pl Mon Aug 19 08:14:09 2002 @@ -15,7 +15,7 @@ If you would like to view the text after the macro expansion pass, use the C<-E> flag. This flag simply tells the assembler to quit after the C<Macro> class -does it thing. +does it thing. The final pass replaces label occurrences with the appropriate PC offset and accumulates the (finally completely numeric) bytecode onto the output string. @@ -126,6 +126,9 @@ package Macro; use Syntax qw($label_re $num_re); +use FindBin; +use lib "$FindBin::Bin/lib"; +use Parrot::PMC qw(%pmc_types); =head2 Macro class @@ -156,24 +159,9 @@ } # - # XXX Must be generated from the enum in include/parrot/pmc.h # bless $self,$class; - $self->{constants}{Array} = 0; - $self->{constants}{Boolean} = 1; - $self->{constants}{PerlUndef} = 2; - $self->{constants}{PerlInt} = 3; - $self->{constants}{PerlNum} = 4; - $self->{constants}{PerlString} = 5; - $self->{constants}{PerlArray} = 6; - $self->{constants}{PerlHash} = 7; - $self->{constants}{Pointer} = 8; - $self->{constants}{IntQueue} = 9; - $self->{constants}{Sub} = 10; - $self->{constants}{Coroutine} = 11; - $self->{constants}{Continuation} = 12; - $self->{constants}{CSub} = 13; - $self->{constants}{MultiArray} = 14; + @{$self->{constants}}{keys %pmc_types} = values %pmc_types; $self; } @@ -211,7 +199,7 @@ =item preprocess Preprocesses constants, macros, include statements, and eventually conditional -compilation. +compilation. .constant name {register} .constant name {signed_integer} @@ -422,7 +410,7 @@ Create a new Assembler instance. - To compile a list of files: + To compile a list of files: $compiler = Assembler->new(-files=>[qw(foo.pasm bar.pasm)]); To compile an array of instructions: @@ -700,7 +688,7 @@ =item constant_table -Constant table returns a hash with the length in bytes of the constant table +Constant table returns a hash with the length in bytes of the constant table and the constant table packed. =cut @@ -708,13 +696,13 @@ sub constant_table { my $self = shift; - # $constl = the length in bytes of the constant table + # $constl = the length in bytes of the constant table my ($constl, $wordsize); my $const = ""; $constl = $wordsize = $PConfig{'opcode_t_size'}; my $packtype = $PConfig{'packtype_op'}; - + for(@{$self->{constants}}) { # if it's a string constant. if ($_->[0] eq 'S') { @@ -742,7 +730,7 @@ # if it's a float constant. elsif ($_->[0] eq 'N') { # The size of the whole constant. - $constl += 2 * $wordsize + $PConfig{numvalsize}; + $constl += 2 * $wordsize + $PConfig{numvalsize}; # Constant type, N $const .= pack($packtype,0x6e); # Sizeof the Parrot floatval. @@ -758,9 +746,9 @@ =item output_bytecode -Returns a string with the Packfile. +Returns a string with the Packfile. -First process the constants and generate the constant table to be able to make +First process the constants and generate the constant table to be able to make the packfile header, then return all. =cut @@ -771,7 +759,7 @@ $wordsize = $PConfig{'opcode_t_size'}; my $packtype = $PConfig{'packtype_op'}; - + my %const_table = constant_table($self); my $byteorder = (substr($PConfig{'byteorder'},0,1) == 1) ? 0 : 1; @@ -1021,7 +1009,7 @@ }); } - + package main; use strict; @@ -1101,7 +1089,7 @@ -E Preprocess input files and terminate processing -h,--help Print this message - -o,--output Write file + -o,--output Write file -c,-checksyntax Check syntax only, do not generate bytecode _EOF_
--- pmc_pm.pl Wed Jan 30 05:20:37 2002 +++ /home/lt/src/parrot-007/pmc_pm.pl Mon Aug 19 08:03:43 2002 @@ -14,12 +14,12 @@ EOF $num = 0; -while (<IN>) { +while (<IN>) { if (/enum_class_(\S+)/) { my $name = $1; $name =~ s/,$//; last if $name eq "max"; - print OUT "\t\L$name => $num,\n"; + print OUT "\t$name => $num,\n"; $num++; } }