Hoi, Is this a pattern? Buggs
Index: Parrot/Opcode.pm =================================================================== RCS file: /home/perlcvs/parrot/Parrot/Opcode.pm,v retrieving revision 1.3 diff -u -3 -p -r1.3 Opcode.pm --- Parrot/Opcode.pm 2001/09/15 00:57:42 1.3 +++ Parrot/Opcode.pm 2001/09/16 01:02:04 @@ -105,89 +105,4 @@ The fingerprint() function returns the M opcode table. =cut -package Parrot::Opcode; -use strict; -use Symbol; - -sub read_ops { - my $file = @_ ? shift : "opcode_table"; - - my $fh = gensym; - open $fh, $file or die "$file: $!\n"; - - my %opcode; - my $count = 1; - while (<$fh>) { - s/#.*//; - s/^\s+//; - chomp; - next unless $_; - - my($name, @params) = split /\s+/; - if (@params && $params[0] =~ /^\d+$/) { - my $count = shift @params; - die "$file, line $.: opcode $name parameters don't match count\n" - if ($count != @params); - } - - warn "$file, line $.: opcode $name redefined\n" if $opcode{$name}; - - $opcode{$name}{ARGS} = @params; - $opcode{$name}{TYPES} = \@params; - $opcode{$name}{CODE} = ($name eq "end") ? 0 : $count++; - $opcode{$name}{FUNC} = "Parrot_op_$name"; - - my $num_i = () = grep {/i/} @params; - my $num_n = () = grep {/n/} @params; - $opcode{$name}{RETURN_OFFSET} = 1 + $num_i + $num_n * 2; - } - - return %opcode; -} - -1; - - -__END__ - -=head1 NAME - -Parrot::Opcode - Read opcode definitions - -=head1 SYNOPSIS - - use Parrot::Opcode; - - %opcodes = Parrot::Opcode::read_ops(); - -=head1 DESCRIPTION - -The read_ops() function parses the Parrot opcode_table file, and -returns the contents as a hash. The hash key is the opcode name; -values are hashrefs containing the following fields: - -=over - -=item CODE - -The opcode number. - -=item ARGS - -The opcode argument count. - -=item TYPES - -The opcode argument types, as an arrayref. - -=item FUNC - -The name of the C function implementing this op. - -=back - -read_ops() takes an optional argument: the file to read the opcode table -from. - -=cut