Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Pmc2c] Continued cleanup and reorg

git-svn-id: https://svn.parrot.org/parrot/trunk@18495 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
commit 59359caa350ae0e61636cd3acb6f67c848247541 1 parent ee80f2b
@tewk tewk authored
View
2  config/inter/pmc.pm
@@ -152,7 +152,7 @@ src/pmc/$pmc.dump : vtable.dump $parent_dumps src/pmc/$pmc.pmc \\
\t\tlib/Parrot/Pmc2c/Ref.pm lib/Parrot/Pmc2c/SharedRef.pm \\
\t\tlib/Parrot/Pmc2c/Standard.pm lib/Parrot/Pmc2c/UtilFunctions.pm \\
\t\tlib/Parrot/Pmc2c/delegate.pm lib/Parrot/Pmc2c/Null.pm \\
-\t\tlib/Parrot/Pmc2c/StandardRO.pm lib/Parrot/Pmc2c/Utils.pm \\
+\t\tlib/Parrot/Pmc2c/StandardRO.pm lib/Parrot/Pmc2c/Pmc2cMain.pm \\
\t\tlib/Parrot/Pmc2c/deleg_pmc.pm lib/Parrot/Pmc2c/PCCMETHOD.pm \\
\t\tlib/Parrot/Pmc2c/StandardConst.pm
\t\$(PMC2CD) src/pmc/$pmc.pmc
View
203 docs/pmc2c.pod
@@ -0,0 +1,203 @@
+=head1 NAME
+
+tools/build/pmc2c.pl - PMC definition to C compiler
+
+=head2 Internals
+
+To see the internal data structures please run:
+
+ % perl tools/build/pmc2c.pl --c --debug --debug sarray.pmc | less
+
+=head2 Compiling PMCs
+
+First, the program determines the names of the .c and .h files from
+the basename of the .pmc file (e.g. F<perlint.pmc> -> F<perlint.c> and
+F<perlint.h>).
+
+Next, the file is searched for C</pmclass \w*/> which attempts to find the
+class being declared.
+
+Once the class is found, all of its superclasses are scanned and their
+methods added to the methods of the current PMC. PMCs default to
+inheriting from 'default'. Only single inheritance is supported.
+
+Once the superclass is determined, it is processed and its method names
+are extracted and saved.
+
+Next, each method body is processed with various directives (see below)
+getting replaced by their appropriate values.
+
+Finally, the .c and .h files are generated. The appropriate base class
+header files are included.
+
+If the C<noinit> flag was used, then no init function is generated.
+Otherwise, one is generated which sets up the vtable and enters it into
+the C<vtables> array.
+
+The .c file is generated by appending the functions after the various
+directives have been replaced.
+
+=head2 PMC File Syntax
+
+The basic syntax of a PMC file is
+
+=over 4
+
+=item 1.
+
+A preamble, consisting of code to be copied directly to the .c file
+
+=item 2.
+
+The C<pmclass> declaration:
+
+ pmclass PMCNAME [flags] {
+
+where C<flags> are:
+
+=over 4
+
+=item C<extends PMCPARENT>
+
+All methods not defined in PMCNAME are inherited from the PMCPARENT class.
+If no parent class is defined, methods from F<default.pmc> are used.
+
+=item C<abstract>
+
+This class cannot be instantiated. Abstract classes are shown with lower
+case class names in the class tree.
+
+=item C<noinit>
+
+Used with C<abstract>: No C<class_init> code is generated.
+
+=item C<const_too>
+
+Classes with this flag get 2 vtables and 2 enums, one pair with
+read/write set methods, and one with read-only set methods.
+
+=item C<need_ext>
+
+The class needs a C<PMC_EXT> structure. For instance, any class using
+C<PMC_data> will have C<need_ext>.
+
+=item C<does interface>
+
+The class 'does' the given interfaces (the collection of methods
+which the class implements).
+
+The default is "scalar". Other currently used interfaces are:
+
+ array : container PMC with numerically-keyed elements
+ event : PMC that can be used with event queue
+ hash : container PMC with string-keyed elements
+ library : PMC that corresponds to a dynamic library
+ ref : PMC that references another PMC
+ string : PMC that behaves similarly to the base string type
+ boolean : PMC that does true/false only.
+ integer : PMC that behaves similarly to the base int type
+ float : PMC that behaves similarly to the base number type
+ scalar : (only used by the sample src/dynpmc/foo.pmc)
+
+This is not a canonical list, but merely a snapshot of what's in use.
+
+=item C<dynpmc>
+
+The class is a dynamic class. These have a special C<class_init>
+routine suitable for dynamic loading at runtime. See the F<src/dynpmc>
+directory for an example.
+
+=item C<group GROUP>
+
+The class is part of a group of interrelated PMCs that should be
+compiled together into a single shared library of the given name. Only
+valid for dynamic PMCs.
+
+=item C<lib LIB>
+
+The class needs an external library.
+
+=item C<hll HLL>
+
+The High level language this PMC corresponds to.
+
+=item C<maps Type>
+
+The basic parrot PMC type that this PMC correspond to for C<.HLL>
+usage. For example:
+
+ pmcclass TclInt hll Tcl maps Integer
+
+allows this PMC to automatically be used when autoboxing C<I> registers to PMCs.
+
+Requires the C<hll> flag.
+
+=back
+
+=item 3.
+
+A list of vtable method implementations
+
+=item 4.
+
+The final close C<}>
+
+=back
+
+=head2 Method Body Substitutions
+
+The vtable method bodies can use the following substitutions:
+
+=over 4
+
+=item C<SELF>
+
+Converted to the current PMC object of type C<PMC *>.
+
+=item C<INTERP>
+
+Converted to the interpreter object.
+
+=item C<OtherClass.SELF.method(a,b,c)>
+
+Calls the static vtable method 'method' in C<OtherClass>.
+
+=item C<SELF.method(a,b,c)>
+
+Calls the vtable method 'method' using the static type of C<SELF> (in
+other words, calls another method defined in the same file).
+
+=item C<DYNSELF.method(a,b,c)>
+
+Calls the vtable method 'method' using the dynamic type of C<SELF>.
+
+=item C<DYNSELF(a,b,c)>
+
+Same as above, but calls the current method.
+
+=item C<OtherClass.SUPER(a,b,c)>
+
+Calls the overridden implementation of the current method in
+C<OtherClass>.
+
+=item C<SUPER(a,b,c)>
+
+Calls the overridden implementation of the current method in the nearest
+superclass, using the static type of C<SELF>.
+
+=item C<DYNSUPER(a,b,c)>
+
+As above, but uses the actual dynamic type of C<SELF>.
+
+=back
+
+=head1 AUTHOR
+
+Leopold Toetsch.
+
+Cleaned up by Matt Diephouse.
+
+Many thanks to the author of F<pmc2c.pl>, many useful code pieces got
+reused.
+
+=cut
View
5 lib/Parrot/Pmc2c/PCCMETHOD.pm
@@ -17,8 +17,7 @@ $SIG{__WARN__} = sub {
=head1 NAME
-Parrot::Pmc2c::Utils::PCCMETHOD - Parses and preps PMC PCCMETHOD
- called from F<Parrot:Pmc2c::Utils>
+Parrot::Pmc2c::PCCMETHOD - Parses and preps PMC PCCMETHOD called from F<Parrot:Pmc2c::Pmc2cMain>
=head1 SYNOPSIS
@@ -26,7 +25,7 @@ Parrot::Pmc2c::Utils::PCCMETHOD - Parses and preps PMC PCCMETHOD
=head1 DESCRIPTION
-Parrot::Pmc2c::PCCMETHOD - Parses and preps PMC PCCMETHOD called from F<Parrot:Pmc2c::Utils>
+Parrot::Pmc2c::PCCMETHOD - Parses and preps PMC PCCMETHOD called from F<Parrot:Pmc2c::Pmc2cMain>
=cut
View
316 lib/Parrot/Pmc2c/Parser.pm
@@ -0,0 +1,316 @@
+# Copyright (C) 2004-2006, The Perl Foundation.
+# $Id: Pmc2cMain.pm 18352 2007-04-28 19:47:02Z jkeenan $
+package Parrot::Pmc2c::Parser;
+use strict;
+use warnings;
+use warnings;
+use base qw( Exporter );
+our @EXPORT_OK = qw( parse_pmc );
+use Parrot::Pmc2c::UtilFunctions qw(count_newlines);
+
+#use Data::Dumper;
+#use Parrot::Vtable;
+#use Parrot::Pmc2c::Library;
+#use Parrot::Pmc2c::UtilFunctions qw(count_newlines);
+#use Parrot::Pmc2c::PCCMETHOD;
+#use Cwd qw(cwd realpath);
+#use File::Basename;
+#use Carp;
+
+=head3 C<parse_pmc()>
+
+ ($classname, $attributesref) = parse_pmc($contents, $opt);
+
+B<Purpose:> Parse PMC code and return the class name and a hash ref of
+attributes.
+
+B<Arguments:> List of two arguments:
+
+=over 4
+
+=item *
+
+Code reference holding results of parsing PMC code found in file provided
+as argument to C<find_and_parse_pmc()>.
+
+=item *
+
+The hash reference which is the value of the C<opt> key provided to constructor.
+
+=back
+
+B<Return Values:> List of two elements:
+
+=over 4
+
+=item *
+
+String holding a classname.
+
+=item *
+
+Reference to a hash of the class's attributes. Keys:
+
+ pre
+ flags
+ methods
+ post
+ class
+ has_method
+
+=back
+
+B<Comments:> Called internally by C<find_and_parse_pmc()>.
+
+=cut
+
+sub parse_pmc {
+ my ( $code, $opt ) = @_;
+
+ my ( $pre, $classname, $flags_ref ) = parse_flags( \$code );
+ my ( $classblock, $post ) = extract_balanced($code);
+
+ my $lineno = 1 + count_newlines($pre);
+ $classblock = substr( $classblock, 1, -1 ); # trim out the { }
+
+ my ( @methods, %meth_hash, $class_init );
+ my $signature_re = qr{
+ ^
+ (?: #blank spaces and comments and spurious semicolons
+ [;\n\s]*
+ (?:/\*.*?\*/)? # C-like comments
+ )*
+
+ ((?:PCC)?METHOD\s+)? #method flag
+
+ (\w+\**) #type
+ \s+
+ (\w+) #method name
+ \s*
+ \( ([^\(]*) \) #parameters
+ \s*
+ ((?::(\w+)\s*)*) #method attrs
+ }sx;
+
+ while ( $classblock =~ s/($signature_re)// ) {
+ $lineno += count_newlines($1);
+ my ( $flag, $type, $methodname, $parameters ) = ( $2, $3, $4, $5 );
+ my $attrs = parse_method_attrs($6);
+ my ( $methodblock, $remainder_part ) = extract_balanced($classblock);
+
+ my $method_hash = {
+ meth => $methodname,
+ body => $methodblock,
+ line => $lineno,
+ type => $type,
+ parameters => $parameters,
+ loc => "vtable",
+ attrs => $attrs,
+ };
+
+ if ( $flag and $flag =~ /PCCMETHOD/ ) {
+ Parrot::Pmc2c::PCCMETHOD::rewrite_pccmethod($method_hash);
+ $flags_ref->{need_fia_header} = 1;
+ }
+
+ if ( $methodblock =~ /PCCINVOKE/ ) {
+ $flags_ref->{need_fia_header} = 1;
+ }
+
+ if ( $methodname eq 'class_init' ) {
+ $class_init = $method_hash;
+ }
+ else {
+
+ # Name-mangle NCI methods to avoid conflict with vtable methods.
+ if ($flag) {
+ $method_hash->{loc} = "nci";
+ $method_hash->{meth} = "nci_$methodname";
+ $method_hash->{symbol} = $methodname;
+ }
+
+ # name => method idx mapping
+ $meth_hash{ $method_hash->{meth} } = scalar @methods;
+
+ $method_hash->{mmds} = [ ( $methodblock =~ /MMD_(\w+):/g ) ];
+ push @methods, $method_hash;
+ }
+
+ $classblock = $remainder_part;
+ $lineno += count_newlines($methodblock);
+ }
+
+ if ($class_init) {
+ $meth_hash{'class_init'} = scalar @methods;
+ push @methods, $class_init;
+ }
+ return
+ {
+ pre => $pre,
+ flags => $flags_ref,
+ methods => \@methods,
+ post => $post,
+ class => $classname,
+ has_method => \%meth_hash,
+ };
+}
+
+=head3 C<parse_flags()>
+
+ ($pre, $classname, $flags_ref) = parse_flags(\$code);
+
+B<Purpose:> Extract a class signature from the code ref.
+
+B<Argument:> De-reference the code ref which was the first argument
+provided to C<parse_pmc()>.
+
+B<Return Values:> List of three elements:
+
+=over 4
+
+=item *
+
+the code found before the class signature;
+
+=item *
+
+the name of the class; and
+
+=item *
+
+a hash ref containing the flags associated with the class (such as
+C<extends> and C<does>).
+
+=back
+
+B<Comments:> Called internally by C<parse_pmc()>.
+
+=cut
+
+sub parse_flags {
+ my $c = shift;
+
+ $$c =~ s/^(.*?^\s*)pmclass ([\w]*)//ms;
+ my ( $pre, $classname ) = ( $1, $2 );
+
+ # flags that have values passed with them
+ my %has_value = map { $_ => 1 } qw(does extends group lib hll maps);
+
+ my ( %flags, $parent_nr );
+
+ # look through the pmc declaration header for flags such as noinit
+ while ( $$c =~ s/^\s*(\w+)//s ) {
+ my $flag = $1;
+ if ( $has_value{$flag} ) {
+ $$c =~ s/^\s+(\w+)//s
+ or die "Parser error: no value for '$flag'";
+
+ $flags{$flag}{$1} = $flag eq 'extends' ? ++$parent_nr : 1;
+ }
+ else {
+ $flags{$flag} = 1;
+ }
+ }
+
+ # setup some defaults
+ if ( $classname ne 'default' ) {
+ $flags{extends}{default} = 1 unless $flags{extends};
+ $flags{does}{scalar} = 1 unless $flags{does};
+ }
+
+ return $pre, $classname, \%flags;
+}
+
+=head3 C<extract_balanced()>
+
+ ($classblock, $post) = extract_balanced($code);
+
+B<Purpose:> Remove a balanced C<{}> construct from the beginning of C<$code>.
+Return it and the remaining code.
+
+B<Argument:> The code ref which was the first argument provided to
+C<parse_pmc()>.
+
+B<Return Values:> List of two elements:
+
+=over 4
+
+=item *
+
+String beginning with C<{> and ending with C<}>. In between is found C code
+where the comments hold strings of Perl comments written in POD.
+
+=item *
+
+String holding the balance of the code. Same style as first element, but
+without the braces.
+
+=back
+
+B<Comments:> Called twice within C<parse_pmc()>. Will die with error message
+C<Badly balanced> if not balanced.
+
+=cut
+
+sub extract_balanced {
+ my $code = shift;
+ my $balance = 0;
+
+ $code =~ s/^\s+//;
+
+ # create a copy and remove strings and comments so that
+ # unbalanced {} can be used in them in PMCs, being careful to
+ # preserve string length.
+ local $_ = $code;
+ s[
+ ( ' (?: \\. | [^'] )* ' # remove ' strings
+ | " (?: \\. | [^"] )* " # remove " strings
+ | /\* .*? \*/ ) # remove C comments
+ ]
+ [ "-" x length $1 ]sexg;
+
+ /^\{/ or die "bad block open: ", substr( $code, 0, 10 ), "...";
+
+ while (/ (\{) | (\}) /gx) {
+ if ($1) {
+ $balance++;
+ }
+ else { # $2
+ $balance--;
+ return substr( $code, 0, pos, "" ), $code
+ if not $balance;
+ }
+ }
+ die "Badly balanced" if $balance;
+ return;
+}
+
+=head3 C<parse_method_attrs()>
+
+ $attrs = parse_method_attrs($method_attributes);
+
+B<Purpose:> Parse a list of method attributes and return a hash ref of them.
+
+B<Arguments:> String captured from regular expression.
+
+B<Return Values:> Reference to hash of attribute values.
+
+B<Comments:> Called within C<parse_pmc()>.
+
+=cut
+
+sub parse_method_attrs {
+ my $flags = shift;
+ my %result;
+ ++$result{$1} while $flags =~ /:(\w+)/g;
+ return \%result;
+}
+
+1;
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
View
459 lib/Parrot/Pmc2c/Utils.pm → lib/Parrot/Pmc2c/Pmc2cMain.pm
@@ -1,29 +1,29 @@
# Copyright (C) 2004-2006, The Perl Foundation.
# $Id$
-package Parrot::Pmc2c::Utils;
+package Parrot::Pmc2c::Pmc2cMain;
use strict;
use warnings;
use FindBin;
use Data::Dumper;
use Parrot::Vtable;
use Parrot::Pmc2c::Library;
-use Parrot::Pmc2c::UtilFunctions qw(count_newlines);
use Parrot::Pmc2c::PCCMETHOD;
+use Parrot::Pmc2c::Parser qw(parse_pmc);
use Cwd qw(cwd realpath);
use File::Basename;
use Carp;
=head1 NAME
-Parrot::Pmc2c::Utils - Functions called within F<tools/build/pmc2c.pl>
+Parrot::Pmc2c::Pmc2cMain - Functions called within F<tools/build/pmc2c.pl>
=head1 SYNOPSIS
- use Parrot::Pmc2c::Utils;
+ use Parrot::Pmc2c::Pmc2cMain;
=head1 DESCRIPTION
-Parrot::Pmc2c::Utils holds subroutines called within F<tools/build/pmc2c.pl>.
+Parrot::Pmc2c::Pmc2cMain holds subroutines called within F<tools/build/pmc2c.pl>.
=cut
@@ -33,13 +33,13 @@ Parrot::Pmc2c::Utils holds subroutines called within F<tools/build/pmc2c.pl>.
=head3 C<new()>
- $self = Parrot::Pmc2c::Utils->new( {
+ $self = Parrot::Pmc2c::Pmc2cMain->new( {
include => \@include,
opt => \%opt,
args => \@args,
} );
-B<Purpose:> Parrot::Pmc2c::Utils constructor.
+B<Purpose:> Parrot::Pmc2c::Pmc2cMain constructor.
B<Arguments:> Reference to a hash holding 3 required keys:
@@ -61,14 +61,14 @@ C<@ARGV> remaining after options processing.
=back
-B<Return Values:> Parrot::Pmc2c::Utils object. Will C<die> with error
+B<Return Values:> Parrot::Pmc2c::Pmc2cMain object. Will C<die> with error
message if arguments are defective.
=cut
sub new {
my ( $class, $allargsref ) = @_;
- die "Must pass a hash ref to Parrot::Pmc2c::Utils::new"
+ die "Must pass a hash ref to Parrot::Pmc2c::Pmc2cMain::new"
unless ref($allargsref) eq q{HASH};
die "Must have key 'include' which is a reference to an array of directories"
unless ( defined $allargsref->{include} and ref( $allargsref->{include} ) eq q{ARRAY} );
@@ -206,7 +206,7 @@ definition of this function. Defaults to C<0> if not specified.
=item * files
Optional. Reference to an array holding a list of files. If not supplied, the
-value of the C<args> key in C<Parrot::Pmc2c::Utils::new()> will be used.
+value of the C<args> key in C<Parrot::Pmc2c::Pmc2cMain::new()> will be used.
(This is used for the recursive call.)
=back
@@ -348,7 +348,7 @@ C<arg> key (which can be found in the directories listed in the C<include> key).
A C<'*.pmc'> glob may also be passed to emulate a proper shell in the presence
of a dumb one.
- $self = Parrot::Pmc2c::Utils->new( {
+ $self = Parrot::Pmc2c::Pmc2cMain->new( {
include => \@include,
opt => \%opt,
args => [ ( q{*.pmc} ) ],
@@ -366,7 +366,6 @@ F<pmc2c.pl>.
sub dump_pmc {
my $self = shift;
- my $include = $self->{include};
my @files = @{ $self->{args} };
my $opt = $self->{opt};
@@ -377,56 +376,40 @@ sub dump_pmc {
# make sure that a default.dump will always be created if it doesn't
# already exist; do so by adding default.pmc to list of files for dumping
- unless ( -e qq{./src/pmc/default.dump} ) {
- unshift @files, qq{./src/pmc/default.pmc};
- }
+ unshift @files, qq{./src/pmc/default.pmc} unless ( -e qq{./src/pmc/default.dump} );
my $all;
for my $file (@files) {
- my ( $class, $result ) = $self->find_and_parse_pmc($file);
- $result->{file} = $file;
- $all->{$class} = $result;
+ $file =~ s/\.\w+$/.pmc/;
+ $file = $self->find_file( $file, 1 );
+
+ #slurp file contents
+ my $fh = open_file( "<", $file );
+ my $contents = do { local $/; <$fh> };
+ close $fh;
+
+ my $parsed_pmc = parse_pmc( $contents, $opt );
+ $parsed_pmc->{file} = $file;
+ $all->{$parsed_pmc->{class}} = $parsed_pmc;
}
- $all->{default} = $self->read_dump("default.pmc")
- if not $all->{default};
+ $all->{default} = $self->read_dump("default.pmc") if not $all->{default};
my $vt = $self->read_dump("vtable.pmc");
- foreach my $e ( @{ $vt->{methods} } ) {
- my $meth = $e->{meth};
- $all->{default}->{super}{$meth} = 'default';
+ foreach my $entry ( @{ $vt->{methods} } ) {
+ my $method_name = $entry->{meth};
+ $all->{default}->{super}{$method_name} = 'default';
}
-DO_A_DUMP: foreach my $name ( keys %{$all} ) {
- my $file = $all->{$name}->{file};
- my $dumpfile = $file;
+ foreach my $name ( keys %{$all} ) {
+ my $dumpfile = $all->{$name}->{file};
$dumpfile =~ s/\.\w+$/.dump/;
-
my $existing = $self->find_file($dumpfile);
- # Am confused about what's intended here. If the .dump file is OLDER
- # than the corresponding .pmc file (e.g., if it's some .dump file from
- # an earlier run of 'make'), shouldn't it be overwritten so that we
- # have an up-to-date .dump file?
- if ( defined $existing && dump_is_newer($existing) ) {
- if ( $dumpfile =~ /default\.dump$/ ) {
-
- # don't overwrite default.dump
- # skip all preparations for dumping
- next DO_A_DUMP;
- }
- else {
-
- # overwrite anything else
- # continue with preparations for dumping
- # And what good is assigning the name of the existing dump file to
- # that of the newly-to-be-created dumpfile. Wouldn't they have the
- # same name in any case? (Or are we dealing with the possibility that
- # find_file() will return a file of the same basename but in a
- # different directory? Is that a real possibility?)
- $dumpfile = $existing;
- }
+ if ( $dumpfile =~ /default\.dump$/ && defined $existing && dump_is_newer($existing) ) {
+ # don't overwrite default.dump skip all preparations for dumping
+ next;
}
$all = $self->gen_parent_list( $name, $all );
@@ -434,6 +417,7 @@ DO_A_DUMP: foreach my $name ( keys %{$all} ) {
my $class = gen_super_meths( $name, $all, $vt );
my $Dumper = Data::Dumper->new( [$class], ['class'] );
$Dumper->Indent(1);
+
my $fh = open_file( ">", $dumpfile );
print $fh $Dumper->Dump;
close $fh;
@@ -443,44 +427,11 @@ DO_A_DUMP: foreach my $name ( keys %{$all} ) {
=head2 Non-Public Methods
-These functions are expressed as methods called on the Parrot::Pmc2c::Utils
+These functions are expressed as methods called on the Parrot::Pmc2c::Pmc2cMain
object, but only because they make use of data stored in that object. They
are called within the publicly available methods described above and are not
intended to be publicly callable.
-=head3 C<find_and_parse_pmc()>
-
- ($class, $result) = $self->find_and_parse_pmc($file);
-
-B<Purpose:> Returns the class structure from C<$file> for a F<.dump> file.
-
-B<Arguments:> String holding a file name. The file is one of those provided
-by the C<arg> key of the constructor.
-
-B<Return Values:> C<find_and_parse_pmc()> internally calls C<parse_pmc> and directly
-returns the latter's list of two return values: a string holding a classname
-and a reference to a hash holding the class's attributes.
-
-B<Comments:> Called internally by C<dump_pmc()>. Formerly called
-C<dump_1_pmc()>; name was changed because this function doesn't actually do
-any 'dumping' in the sense of using Data::Dumper to print the contents of a
-variable. Rather, it is a step called by C<dump_pmc()> to prepare for dumping.
-
-=cut
-
-sub find_and_parse_pmc {
- my ( $self, $file ) = @_;
- my $opt = $self->{opt};
- $file =~ s/\.\w+$/.pmc/;
- $file = $self->find_file( $file, 1 );
-
- my $fh = open_file( "<", $file );
- my $contents = do { local $/; <$fh> };
- close $fh;
- my ( $classname, $attributesref ) = parse_pmc( $contents, $opt );
- return ( $classname, $attributesref );
-}
-
=head3 C<gen_parent_list()>
$self->gen_parent_list($name, \%all);
@@ -511,28 +462,33 @@ B<Comments:> Called within C<dump_pmc()>.
=cut
sub gen_parent_list {
- my ( $self, $name, $all ) = @_;
- my $class = $all->{$name};
+ my ( $self, $pmc_name, $all ) = @_;
+ my $pmc_class = $all->{$pmc_name};
# An interesting construction: note below that in the course of processing
# @todo, new elements can be pushed on to it. So it's not necessarily
# exhausted when $n is shifted off it.
- my @todo = ($name);
+ my @todo = ($pmc_name);
while (@todo) {
- my $n = shift @todo;
- my $sub = $all->{$n};
- next if $n eq 'default';
-
- my %parent_hash = %{ $sub->{flags}{extends} };
- my @parents =
- sort { $parent_hash{$a} <=> $parent_hash{$b} } keys %parent_hash;
- for my $parent (@parents) {
- $all->{$parent} = $self->read_dump( lc("$parent.pmc") )
- if not $all->{$parent};
-
- $class->{has_parent}{$parent} = { %{ $all->{$parent}{has_method} } };
- push @todo, $parent;
- push @{ $class->{parents} }, $parent;
+ my $current_pmc_name = shift @todo;
+ next if $current_pmc_name eq 'default';
+ my $current_pmc = $all->{$current_pmc_name};
+
+ #generate list of parent_names and sort by extends order
+ my %parent_hash = %{ $current_pmc->{flags}{extends} };
+ my @parent_names = sort { $parent_hash{$a} <=> $parent_hash{$b} } keys %parent_hash;
+
+ for my $parent_name (@parent_names) {
+ #load $parent_name into $all
+ $all->{$parent_name} =
+ $self->read_dump( lc("$parent_name.pmc") ) if not $all->{$parent_name};
+
+ #add parent's has_method hash to pmc_class' has_parent hash
+ $pmc_class->{has_parent}{$parent_name} = { %{ $all->{$parent_name}{has_method} } };
+ #add parent_name to parents lists
+ push @{ $pmc_class->{parents} }, $parent_name;
+ #add parent_name to recursion list.
+ push @todo, $parent_name;
}
}
return $all;
@@ -579,305 +535,14 @@ and C<dump_pmc()>.
sub open_file {
my ( $direction, $filename, $verbose ) = @_;
- my $action =
- ( $direction eq "<" ) ? "Reading"
- : ( $direction eq ">>" ) ? "Appending"
- : "Writing";
+ my $actions_descriptions = { '<' => 'Reading', '>>' => "Appending", '>' => "Writing" };
+ my $action = $actions_descriptions->{$direction} || "Unknown";
print "$action $filename\n" if $verbose;
open my $fh, $direction, $filename or die "$action $filename: $!\n";
return $fh;
}
-=head3 C<parse_pmc()>
-
- ($classname, $attributesref) = parse_pmc($contents, $opt);
-
-B<Purpose:> Parse PMC code and return the class name and a hash ref of
-attributes.
-
-B<Arguments:> List of two arguments:
-
-=over 4
-
-=item *
-
-Code reference holding results of parsing PMC code found in file provided
-as argument to C<find_and_parse_pmc()>.
-
-=item *
-
-The hash reference which is the value of the C<opt> key provided to constructor.
-
-=back
-
-B<Return Values:> List of two elements:
-
-=over 4
-
-=item *
-
-String holding a classname.
-
-=item *
-
-Reference to a hash of the class's attributes. Keys:
-
- pre
- flags
- methods
- post
- class
- has_method
-
-=back
-
-B<Comments:> Called internally by C<find_and_parse_pmc()>.
-
-=cut
-
-sub parse_pmc {
- my ( $code, $opt ) = @_;
-
- my ( $pre, $classname, $flags_ref ) = parse_flags( \$code );
- my ( $classblock, $post ) = extract_balanced($code);
-
- my $lineno = 1 + count_newlines($pre);
- $classblock = substr( $classblock, 1, -1 ); # trim out the { }
-
- my ( @methods, %meth_hash, $class_init );
- my $signature_re = qr{
- ^
- (?: #blank spaces and comments and spurious semicolons
- [;\n\s]*
- (?:/\*.*?\*/)? # C-like comments
- )*
-
- ((?:PCC)?METHOD\s+)? #method flag
-
- (\w+\**) #type
- \s+
- (\w+) #method name
- \s*
- \( ([^\(]*) \) #parameters
- \s*
- ((?::(\w+)\s*)*) #method attrs
- }sx;
-
- while ( $classblock =~ s/($signature_re)// ) {
- $lineno += count_newlines($1);
- my ( $flag, $type, $methodname, $parameters ) = ( $2, $3, $4, $5 );
- my $attrs = parse_method_attrs($6);
- my ( $methodblock, $remainder_part ) = extract_balanced($classblock);
-
- my $method_hash = {
- meth => $methodname,
- body => $methodblock,
- line => $lineno,
- type => $type,
- parameters => $parameters,
- loc => "vtable",
- attrs => $attrs,
- };
-
- if ( $flag and $flag =~ /PCCMETHOD/ ) {
- Parrot::Pmc2c::PCCMETHOD::rewrite_pccmethod($method_hash);
- $flags_ref->{need_fia_header} = 1;
- }
-
- if ( $methodblock =~ /PCCINVOKE/ ) {
- $flags_ref->{need_fia_header} = 1;
- }
-
- if ( $methodname eq 'class_init' ) {
- $class_init = $method_hash;
- }
- else {
-
- # Name-mangle NCI methods to avoid conflict with vtable methods.
- if ($flag) {
- $method_hash->{loc} = "nci";
- $method_hash->{meth} = "nci_$methodname";
- $method_hash->{symbol} = $methodname;
- }
-
- # name => method idx mapping
- $meth_hash{ $method_hash->{meth} } = scalar @methods;
-
- $method_hash->{mmds} = [ ( $methodblock =~ /MMD_(\w+):/g ) ];
- push @methods, $method_hash;
- }
-
- $classblock = $remainder_part;
- $lineno += count_newlines($methodblock);
- }
-
- if ($class_init) {
- $meth_hash{'class_init'} = scalar @methods;
- push @methods, $class_init;
- }
- return $classname,
- {
- pre => $pre,
- flags => $flags_ref,
- methods => \@methods,
- post => $post,
- class => $classname,
- has_method => \%meth_hash,
- };
-}
-
-=head3 C<parse_flags()>
-
- ($pre, $classname, $flags_ref) = parse_flags(\$code);
-
-B<Purpose:> Extract a class signature from the code ref.
-
-B<Argument:> De-reference the code ref which was the first argument
-provided to C<parse_pmc()>.
-
-B<Return Values:> List of three elements:
-
-=over 4
-
-=item *
-
-the code found before the class signature;
-
-=item *
-
-the name of the class; and
-
-=item *
-
-a hash ref containing the flags associated with the class (such as
-C<extends> and C<does>).
-
-=back
-
-B<Comments:> Called internally by C<parse_pmc()>.
-
-=cut
-
-sub parse_flags {
- my $c = shift;
-
- $$c =~ s/^(.*?^\s*)pmclass ([\w]*)//ms;
- my ( $pre, $classname ) = ( $1, $2 );
-
- # flags that have values passed with them
- my %has_value = map { $_ => 1 } qw(does extends group lib hll maps);
-
- my ( %flags, $parent_nr );
-
- # look through the pmc declaration header for flags such as noinit
- while ( $$c =~ s/^\s*(\w+)//s ) {
- my $flag = $1;
- if ( $has_value{$flag} ) {
- $$c =~ s/^\s+(\w+)//s
- or die "Parser error: no value for '$flag'";
-
- $flags{$flag}{$1} = $flag eq 'extends' ? ++$parent_nr : 1;
- }
- else {
- $flags{$flag} = 1;
- }
- }
-
- # setup some defaults
- if ( $classname ne 'default' ) {
- $flags{extends}{default} = 1 unless $flags{extends};
- $flags{does}{scalar} = 1 unless $flags{does};
- }
-
- return $pre, $classname, \%flags;
-}
-
-=head3 C<extract_balanced()>
-
- ($classblock, $post) = extract_balanced($code);
-
-B<Purpose:> Remove a balanced C<{}> construct from the beginning of C<$code>.
-Return it and the remaining code.
-
-B<Argument:> The code ref which was the first argument provided to
-C<parse_pmc()>.
-
-B<Return Values:> List of two elements:
-
-=over 4
-
-=item *
-
-String beginning with C<{> and ending with C<}>. In between is found C code
-where the comments hold strings of Perl comments written in POD.
-
-=item *
-
-String holding the balance of the code. Same style as first element, but
-without the braces.
-
-=back
-
-B<Comments:> Called twice within C<parse_pmc()>. Will die with error message
-C<Badly balanced> if not balanced.
-
-=cut
-
-sub extract_balanced {
- my $code = shift;
- my $balance = 0;
-
- $code =~ s/^\s+//;
-
- # create a copy and remove strings and comments so that
- # unbalanced {} can be used in them in PMCs, being careful to
- # preserve string length.
- local $_ = $code;
- s[
- ( ' (?: \\. | [^'] )* ' # remove ' strings
- | " (?: \\. | [^"] )* " # remove " strings
- | /\* .*? \*/ ) # remove C comments
- ]
- [ "-" x length $1 ]sexg;
-
- /^\{/ or die "bad block open: ", substr( $code, 0, 10 ), "...";
-
- while (/ (\{) | (\}) /gx) {
- if ($1) {
- $balance++;
- }
- else { # $2
- $balance--;
- return substr( $code, 0, pos, "" ), $code
- if not $balance;
- }
- }
- die "Badly balanced" if $balance;
- return;
-}
-
-=head3 C<parse_method_attrs()>
-
- $attrs = parse_method_attrs($method_attributes);
-
-B<Purpose:> Parse a list of method attributes and return a hash ref of them.
-
-B<Arguments:> String captured from regular expression.
-
-B<Return Values:> Reference to hash of attribute values.
-
-B<Comments:> Called within C<parse_pmc()>.
-
-=cut
-
-sub parse_method_attrs {
- my $flags = shift;
- my %result;
- ++$result{$1} while $flags =~ /:(\w+)/g;
- return \%result;
-}
-
=head3 C<dump_is_newer()>
dump_is_newer($existing);
@@ -1023,10 +688,8 @@ sub inherit_attrs {
if ( ( $super_attrs->{read} or $super_attrs->{write} )
and not( $attrs->{read} or $attrs->{write} ) )
{
- $attrs->{read} = $super_attrs->{read}
- if exists $super_attrs->{read};
- $attrs->{write} = $super_attrs->{write}
- if exists $super_attrs->{write};
+ $attrs->{read} = $super_attrs->{read} if exists $super_attrs->{read};
+ $attrs->{write} = $super_attrs->{write} if exists $super_attrs->{write};
}
return $class;
}
@@ -1034,7 +697,7 @@ sub inherit_attrs {
=head1 AUTHOR
Leopold Toetsch wrote F<pmc2c.pl>. It was cleaned up by Matt Diephouse.
-James E Keenan extracted the subroutines into F<lib/Parrot/Pmc2c/Utils.pm> and
+James E Keenan extracted the subroutines into F<lib/Parrot/Pmc2c/Pmc2cMain.pm> and
wrote the accompanying test suite.
=head1 SEE ALSO
View
10 t/tools/pmc2cutils/00-qualify.t
@@ -8,7 +8,7 @@ use warnings;
use Test::More tests => 10;
use FindBin;
use lib ( "$FindBin::Bin/../..", "$FindBin::Bin/../../lib", "$FindBin::Bin/../../../lib", );
-use_ok('Parrot::Pmc2c::Utils');
+use_ok('Parrot::Pmc2c::Pmc2cMain');
ok( -f "$FindBin::Bin/../../../Makefile", "Makefile located" );
ok( -f "$FindBin::Bin/../../../myconfig", "myconfig located" );
@@ -47,7 +47,7 @@ my $message = <<END_OF_MESSAGE;
The files in this directory test the publicly callable methods of
-Parrot::Pmc2c::Utils. By doing so, they test the functionality
+Parrot::Pmc2c::Pmc2cMain. By doing so, they test the functionality
of the pmc2c.pl utility.
Since pmc2c.pl is invoked many times during 'make', tests of its
@@ -59,7 +59,7 @@ that point in the build process, but some will necessarily fail
if 'make' has already been executed. Hence, they should not be
included in the set of tests run by 'make test'.
-In short, these are tests of Parrot::Pmc2c::Utils but are *not*
+In short, these are tests of Parrot::Pmc2c::Pmc2cMain but are *not*
tests of Parrot itself.
END_OF_MESSAGE
@@ -79,9 +79,9 @@ pass("Completed all tests in $0");
=head1 DESCRIPTION
The files in this directory test the publicly callable methods of
-F<lib/Parrot/Pmc2c/Utils.pm>. By doing so, they test the functionality
+F<lib/Parrot/Pmc2c/Pmc2cMain.pm>. By doing so, they test the functionality
of the F<pmc2c.pl> utility. That functionality has largely been extracted
-into the methods of F<Utils.pm>.
+into the methods of F<Pmc2cMain.pm>.
Since F<pmc2c.pl> is invoked during C<make>, tests of its functionality can
give meaningful results only if they take into consideration the status of the
View
42 t/tools/pmc2cutils/01-pmc2cutils.t
@@ -19,40 +19,40 @@ BEGIN {
}
unshift @INC, qq{$topdir/lib};
}
-use Test::More tests => 26;
+use Test::More tests => 25;
-use_ok('Parrot::Pmc2c::Utils');
+use_ok('Parrot::Pmc2c::Pmc2cMain');
my ( %opt, @include, @args );
my $self;
-$self = Parrot::Pmc2c::Utils->new(
+$self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
-isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
can_ok( $self, q{find_file} );
can_ok( $self, q{dump_vtable} );
can_ok( $self, q{open_file} );
can_ok( $self, q{print_tree} );
can_ok( $self, q{read_dump} );
can_ok( $self, q{gen_c} );
-can_ok( $self, q{extract_balanced} );
-can_ok( $self, q{parse_flags} );
-can_ok( $self, q{parse_method_attrs} );
can_ok( $self, q{inherit_attrs} );
-can_ok( $self, q{parse_pmc} );
can_ok( $self, q{gen_parent_list} );
-can_ok( $self, q{find_and_parse_pmc} );
can_ok( $self, q{gen_super_meths} );
can_ok( $self, q{dump_is_newer} );
can_ok( $self, q{dump_pmc} );
+can_ok( 'Parrot::Pmc2c::Parser', q{parse_pmc} );
+can_ok( 'Parrot::Pmc2c::Parser', q{parse_flags} );
+can_ok( 'Parrot::Pmc2c::Parser', q{parse_method_attrs} );
+can_ok( 'Parrot::Pmc2c::Parser', q{extract_balanced} );
+
eval {
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
[
include => \@include,
opt => \%opt,
@@ -62,46 +62,46 @@ eval {
};
like(
$@,
- qr/Must pass a hash ref to Parrot::Pmc2c::Utils::new/,
+ qr/Must pass a hash ref to Parrot::Pmc2c::Pmc2cMain::new/,
"Constructor correctly failed due to lack of hash ref as argument"
);
-eval { $self = Parrot::Pmc2c::Utils->new( { opt => \%opt, args => [@args], } ); };
+eval { $self = Parrot::Pmc2c::Pmc2cMain->new( { opt => \%opt, args => [@args], } ); };
like(
$@,
qr/Must have key 'include' which is a reference to an array of directories/,
"Constructor correctly failed due to lack of 'include' key"
);
-eval { $self = Parrot::Pmc2c::Utils->new( { include => {}, opt => \%opt, args => [@args], } ); };
+eval { $self = Parrot::Pmc2c::Pmc2cMain->new( { include => {}, opt => \%opt, args => [@args], } ); };
like(
$@,
qr/Must have key 'include' which is a reference to an array of directories/,
"Constructor correctly failed due to 'include' key's value not being array ref"
);
-eval { $self = Parrot::Pmc2c::Utils->new( { include => \@include, args => [@args], } ); };
+eval { $self = Parrot::Pmc2c::Pmc2cMain->new( { include => \@include, args => [@args], } ); };
like(
$@,
qr/Must have key 'opt' which is a reference to a hash of option values/,
"Constructor correctly failed due to lack of 'opt' key"
);
-eval { $self = Parrot::Pmc2c::Utils->new( { include => \@include, opt => [], args => [@args], } ); };
+eval { $self = Parrot::Pmc2c::Pmc2cMain->new( { include => \@include, opt => [], args => [@args], } ); };
like(
$@,
qr/Must have key 'opt' which is a reference to a hash of option values/,
"Constructor correctly failed due to 'opt' key's lack of hash ref as argument"
);
-eval { $self = Parrot::Pmc2c::Utils->new( { include => \@include, opt => \%opt, } ); };
+eval { $self = Parrot::Pmc2c::Pmc2cMain->new( { include => \@include, opt => \%opt, } ); };
like(
$@,
qr/Must have key 'args' which is a reference to a list of the remaining arguments/,
"Constructor correctly failed due to lack of 'args' key"
);
-eval { $self = Parrot::Pmc2c::Utils->new( { include => \@include, opt => \%opt, args => {}, } ); };
+eval { $self = Parrot::Pmc2c::Pmc2cMain->new( { include => \@include, opt => \%opt, args => {}, } ); };
like(
$@,
qr/Must have key 'args' which is a reference to a list of the remaining arguments/,
@@ -114,7 +114,7 @@ pass("Completed all tests in $0");
=head1 NAME
-01-pmc2cutils.t - test Parrot::Pmc2c::Utils basic functionality
+01-pmc2cutils.t - test Parrot::Pmc2c::Pmc2cMain basic functionality
=head1 SYNOPSIS
@@ -123,9 +123,9 @@ pass("Completed all tests in $0");
=head1 DESCRIPTION
The files in this directory test the publicly callable methods of
-F<lib/Parrot/Pmc2c/Utils.pm>. By doing so, they test the functionality
+F<lib/Parrot/Pmc2c/Pmc2cMain.pm>. By doing so, they test the functionality
of the F<pmc2c.pl> utility. That functionality has largely been extracted
-into the methods of F<Utils.pm>.
+into the methods of F<Pmc2cMain.pm>.
F<01-pmc2cutils.t> consists solely of:
@@ -134,7 +134,7 @@ F<01-pmc2cutils.t> consists solely of:
=item 1
calls to C<Test::More::isa_ok()> and C<can_ok()> on the
-constructor and publicly available methods of Parrot::Pmc2c::Utils; and
+constructor and publicly available methods of Parrot::Pmc2c::Pmc2cMain; and
=item 2
View
12 t/tools/pmc2cutils/02-find_file.t
@@ -20,14 +20,14 @@ BEGIN {
unshift @INC, qq{$topdir/lib};
}
use Test::More tests => 7;
-use_ok('Parrot::Pmc2c::Utils');
+use_ok('Parrot::Pmc2c::Pmc2cMain');
my ( %opt, @include, @args );
my $self;
my $pmcdir = qq{$main::topdir/src/pmc};
@include = ($pmcdir);
-$self = Parrot::Pmc2c::Utils->new(
+$self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
@@ -65,7 +65,7 @@ pass("Completed all tests in $0");
=head1 NAME
-02-find_file.t - test C<Parrot::Pmc2c::Utils::find_file()>
+02-find_file.t - test C<Parrot::Pmc2c::Pmc2cMain::find_file()>
=head1 SYNOPSIS
@@ -74,11 +74,11 @@ pass("Completed all tests in $0");
=head1 DESCRIPTION
The files in this directory test the publicly callable methods of
-F<lib/Parrot/Pmc2c/Utils.pm>. By doing so, they test the functionality
+F<lib/Parrot/Pmc2c/Pmc2cMain.pm>. By doing so, they test the functionality
of the F<pmc2c.pl> utility. That functionality has largely been extracted
-into the methods of F<Utils.pm>.
+into the methods of F<Pmc2cMain.pm>.
-F<02-find_file.t> tests C<Parrot::Pmc2c::Utils::find_file()>, which is
+F<02-find_file.t> tests C<Parrot::Pmc2c::Pmc2cMain::find_file()>, which is
called within other Parrot::Pmc2c::Util methods. The tests assume a certain
file structure in the Parrot tarball; they may no longer be valid if that
structure changes in the future.
View
14 t/tools/pmc2cutils/03-dump_vtable.t
@@ -20,7 +20,7 @@ BEGIN {
unshift @INC, qq{$topdir/lib};
}
use Test::More tests => 12;
-use_ok('Parrot::Pmc2c::Utils');
+use_ok('Parrot::Pmc2c::Pmc2cMain');
use_ok('File::Basename');
use_ok( 'File::Temp', qw| tempdir | );
use Data::Dumper;
@@ -36,7 +36,7 @@ my $cwd;
my $tdir1 = tempdir( CLEANUP => 1 );
ok( chdir $tdir1, 'changed to temp directory for testing' );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
@@ -58,7 +58,7 @@ my $cwd;
ok( chdir $tdir2, 'changed to temp directory for testing' );
%opt = ( verbose => 1 );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
@@ -84,7 +84,7 @@ pass("Completed all tests in $0");
=head1 NAME
-03-dump_vtable.t - test C<Parrot::Pmc2c::Utils::dump_vtable()>
+03-dump_vtable.t - test C<Parrot::Pmc2c::Pmc2cMain::dump_vtable()>
=head1 SYNOPSIS
@@ -93,11 +93,11 @@ pass("Completed all tests in $0");
=head1 DESCRIPTION
The files in this directory test the publicly callable methods of
-F<lib/Parrot/Pmc2c/Utils.pm>. By doing so, they test the functionality
+F<lib/Parrot/Pmc2c/Pmc2cMain.pm>. By doing so, they test the functionality
of the F<pmc2c.pl> utility. That functionality has largely been extracted
-into the methods of F<Utils.pm>.
+into the methods of F<Pmc2cMain.pm>.
-F<03-dump_vtable.t> tests the C<Parrot::Pmc2c::Utils::dump_vtable()> method.
+F<03-dump_vtable.t> tests the C<Parrot::Pmc2c::Pmc2cMain::dump_vtable()> method.
F<make> calls this method when it calls in C<tools/build/pmc2c.pl --vtable>.
When all of F<pmc2c.pl>'s functionality was contained within that program,
View
66 t/tools/pmc2cutils/04-dump_pmc.t
@@ -24,7 +24,7 @@ use File::Basename;
use File::Copy;
use FindBin;
use Data::Dumper;
-use_ok('Parrot::Pmc2c::Utils');
+use_ok('Parrot::Pmc2c::Pmc2cMain');
use_ok('Cwd');
use_ok( 'File::Temp', qw| tempdir | );
@@ -57,14 +57,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -95,14 +95,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, qq{$temppmcdir/array.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -136,14 +136,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = (qq{$temppmcdir/default.pmc});
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -151,14 +151,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
ok( -f qq{$temppmcdir/default.dump}, "default.dump created as expected" );
@args = (qq{$temppmcdir/array.pmc});
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
ok( $self->dump_pmc(), "dump_pmc succeeded" );
ok( -f qq{$temppmcdir/array.dump}, "array.dump created as expected" );
@@ -186,14 +186,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, qq{$temppmcdir/null.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -231,14 +231,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
qq{$temppmcdir/default.pmc}, qq{$temppmcdir/scalar.pmc},
qq{$temppmcdir/integer.pmc}, qq{$temppmcdir/boolean.pmc},
);
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -282,14 +282,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
# qq{$temppmcdir/scalar.pmc},
qq{$temppmcdir/integer.pmc},
);
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -324,14 +324,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => { verbose => 1 },
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
my ( $fh, $currfh, $msg );
{
@@ -380,14 +380,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ('src/pmc/*.pmc');
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -419,14 +419,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = (q{zxssysdfksdjksdfkj.pmc});
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -462,14 +462,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, qq{$temppmcdir/array.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -519,14 +519,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/array.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -543,7 +543,7 @@ pass("Completed all tests in $0");
=head1 NAME
-04-dump_pmc.t - test C<Parrot::Pmc2c::Utils::dump_pmc()>
+04-dump_pmc.t - test C<Parrot::Pmc2c::Pmc2cMain::dump_pmc()>
=head1 SYNOPSIS
@@ -552,11 +552,11 @@ pass("Completed all tests in $0");
=head1 DESCRIPTION
The files in this directory test the publicly callable methods of
-F<lib/Parrot/Pmc2c/Utils.pm>. By doing so, they test the functionality
+F<lib/Parrot/Pmc2c/Pmc2cMain.pm>. By doing so, they test the functionality
of the F<pmc2c.pl> utility. That functionality has largely been extracted
-into the methods of F<Utils.pm>.
+into the methods of F<Pmc2cMain.pm>.
-F<04-dump_pmc.t> tests the C<Parrot::Pmc2c::Utils::dump_pmc()> method.
+F<04-dump_pmc.t> tests the C<Parrot::Pmc2c::Pmc2cMain::dump_pmc()> method.
F<make> calls this method when it calls in C<tools/build/pmc2c.pl --dump>.
So as not to pollute the Parrot build directories with files created
@@ -581,7 +581,7 @@ pass("Completed all tests in $0");
=head1 NAME
-04-dump_pmc.t - test C<Parrot::Pmc2c::Utils::dump_pmc()>
+04-dump_pmc.t - test C<Parrot::Pmc2c::Pmc2cMain::dump_pmc()>
=head1 SYNOPSIS
@@ -590,11 +590,11 @@ pass("Completed all tests in $0");
=head1 DESCRIPTION
The files in this directory test the publicly callable methods of
-F<lib/Parrot/Pmc2c/Utils.pm>. By doing so, they test the functionality
+F<lib/Parrot/Pmc2c/Pmc2cMain.pm>. By doing so, they test the functionality
of the F<pmc2c.pl> utility. That functionality has largely been extracted
-into the methods of F<Utils.pm>.
+into the methods of F<Pmc2cMain.pm>.
-F<04-dump_pmc.t> tests the C<Parrot::Pmc2c::Utils::dump_pmc()> method.
+F<04-dump_pmc.t> tests the C<Parrot::Pmc2c::Pmc2cMain::dump_pmc()> method.
F<make> calls this method when it calls in C<tools/build/pmc2c.pl --dump>.
So as not to pollute the Parrot build directories with files created
View
34 t/tools/pmc2cutils/05-gen_c.t
@@ -24,7 +24,7 @@ use File::Basename;
use File::Copy;
use FindBin;
use Data::Dumper;
-use_ok('Parrot::Pmc2c::Utils');
+use_ok('Parrot::Pmc2c::Pmc2cMain');
use_ok('Cwd');
use_ok( 'File::Temp', qw| tempdir | );
@@ -57,14 +57,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -98,14 +98,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, qq{$temppmcdir/array.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -141,14 +141,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
@args = ( qq{$temppmcdir/default.pmc}, );
my %opt = ( debug => 1 );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -190,14 +190,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
@args = ( qq{$temppmcdir/default.pmc}, );
my %opt = ( debug => 2, verbose => 1 );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
my ( $fh, $msg, $rv );
{
@@ -251,14 +251,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, qq{$temppmcdir/array.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -295,14 +295,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, qq{$temppmcdir/class.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -322,7 +322,7 @@ pass("Completed all tests in $0");
=head1 NAME
-05-gen_c.t - test C<Parrot::Pmc2c::Utils::gen_c()>
+05-gen_c.t - test C<Parrot::Pmc2c::Pmc2cMain::gen_c()>
=head1 SYNOPSIS
@@ -331,11 +331,11 @@ pass("Completed all tests in $0");
=head1 DESCRIPTION
The files in this directory test the publicly callable methods of
-F<lib/Parrot/Pmc2c/Utils.pm>. By doing so, they test the functionality
+F<lib/Parrot/Pmc2c/Pmc2cMain.pm>. By doing so, they test the functionality
of the F<pmc2c.pl> utility. That functionality has largely been extracted
-into the methods of F<Utils.pm>.
+into the methods of F<Pmc2cMain.pm>.
-F<05-gen_c.t> tests the C<Parrot::Pmc2c::Utils::gen_c()> method.
+F<05-gen_c.t> tests the C<Parrot::Pmc2c::Pmc2cMain::gen_c()> method.
F<make> calls this method when it calls in C<tools/build/pmc2c.pl --c>.
So as not to pollute the Parrot build directories with files created
View
30 t/tools/pmc2cutils/06-print_tree.t
@@ -24,7 +24,7 @@ use File::Basename;
use File::Copy;
use FindBin;
use Data::Dumper;
-use_ok('Parrot::Pmc2c::Utils');
+use_ok('Parrot::Pmc2c::Pmc2cMain');
use_ok('Cwd');
use_ok( 'File::Temp', qw| tempdir | );
@@ -58,14 +58,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -107,14 +107,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, qq{$temppmcdir/array.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -160,14 +160,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, qq{$temppmcdir/array.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -213,14 +213,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ( qq{$temppmcdir/default.pmc}, qq{$temppmcdir/array.pmc}, );
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -256,14 +256,14 @@ my @include_orig = ( qq{$main::topdir}, qq{$main::topdir/src/pmc}, );
my @include = ( $tdir, $temppmcdir, @include_orig );
@args = ();
- $self = Parrot::Pmc2c::Utils->new(
+ $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@include,
opt => \%opt,
args => [@args],
}
);
- isa_ok( $self, q{Parrot::Pmc2c::Utils} );
+ isa_ok( $self, q{Parrot::Pmc2c::Pmc2cMain} );
$dump_file = $self->dump_vtable("$main::topdir/vtable.tbl");
ok( -e $dump_file, "dump_vtable created vtable.dump" );
@@ -283,7 +283,7 @@ pass("Completed all tests in $0");
=head1 NAME
-06-print_tree.t - test C<Parrot::Pmc2c::Utils::print_tree()>
+06-print_tree.t - test C<Parrot::Pmc2c::Pmc2cMain::print_tree()>
=head1 SYNOPSIS
@@ -292,11 +292,11 @@ pass("Completed all tests in $0");
=head1 DESCRIPTION
The files in this directory test the publicly callable methods of
-F<lib/Parrot/Pmc2c/Utils.pm>. By doing so, they test the functionality
+F<lib/Parrot/Pmc2c/Pmc2cMain.pm>. By doing so, they test the functionality
of the F<pmc2c.pl> utility. That functionality has largely been extracted
-into the methods of F<Utils.pm>.
+into the methods of F<Pmc2cMain.pm>.
-F<06-print_tree.t> tests the C<Parrot::Pmc2c::Utils::print_tree()> method.
+F<06-print_tree.t> tests the C<Parrot::Pmc2c::Pmc2cMain::print_tree()> method.
This method is I<not> called F<make>. It appears to be intended as an aid in
debugging once F<make> has run.
View
24 t/tools/pmc2cutils/07-open_file.t
@@ -24,7 +24,7 @@ use File::Basename;
use File::Copy;
use FindBin;
use Data::Dumper;
-use_ok('Parrot::Pmc2c::Utils');
+use_ok('Parrot::Pmc2c::Pmc2cMain');
use_ok('Cwd');
use_ok( 'File::Temp', qw| tempdir | );
@@ -45,17 +45,17 @@ my $fh;
ok( create_test_file($file), "test file created" );
$direction = '<';
- ok( $fh = Parrot::Pmc2c::Utils::open_file( $direction, $file, $verbose ),
+ ok( $fh = Parrot::Pmc2c::Pmc2cMain::open_file( $direction, $file, $verbose ),
"file opened for reading" );
close $fh or die "Unable to close handle to test file";
$direction = '>';
- ok( $fh = Parrot::Pmc2c::Utils::open_file( $direction, $file, $verbose ),
+ ok( $fh = Parrot::Pmc2c::Pmc2cMain::open_file( $direction, $file, $verbose ),
"file opened for writing" );
close $fh or die "Unable to close handle to test file";
$direction = '>>';
- ok( $fh = Parrot::Pmc2c::Utils::open_file( $direction, $file, $verbose ),
+ ok( $fh = Parrot::Pmc2c::Pmc2cMain::open_file( $direction, $file, $verbose ),
"file opened for appending" );
close $fh or die "Unable to close handle to test file";
@@ -75,7 +75,7 @@ my $fh;
{
$currfh = select($msgfh);
open( $msgfh, '>', \$msg ) or die "Unable to open handle: $!";
- $fh = Parrot::Pmc2c::Utils::open_file( $direction, $file, $verbose );
+ $fh = Parrot::Pmc2c::Pmc2cMain::open_file( $direction, $file, $verbose );
ok( $fh, "file opened for reading" );
close $fh or die "Unable to close handle: $!";
select($currfh);
@@ -86,7 +86,7 @@ my $fh;
{
$currfh = select($msgfh);
open( $msgfh, '>', \$msg ) or die "Unable to open handle: $!";
- $fh = Parrot::Pmc2c::Utils::open_file( $direction, $file, $verbose );
+ $fh = Parrot::Pmc2c::Pmc2cMain::open_file( $direction, $file, $verbose );
ok( $fh, "file opened for writing" );
close $fh or die "Unable to close handle: $!";
select($currfh);
@@ -97,7 +97,7 @@ my $fh;
{
$currfh = select($msgfh);
open( $msgfh, '>', \$msg ) or die "Unable to open handle: $!";
- $fh = Parrot::Pmc2c::Utils::open_file( $direction, $file, $verbose );
+ $fh = Parrot::Pmc2c::Pmc2cMain::open_file( $direction, $file, $verbose );
ok( $fh, "file opened for appending" );
close $fh or die "Unable to close handle: $!";
select($currfh);
@@ -118,7 +118,7 @@ my $fh;
{
$currfh = select($msgfh);
open( $msgfh, '>', \$msg ) or die "Unable to open handle: $!";
- eval { $fh = Parrot::Pmc2c::Utils::open_file( $direction, $file, $verbose ); };
+ eval { $fh = Parrot::Pmc2c::Pmc2cMain::open_file( $direction, $file, $verbose ); };
select($currfh);
}
like( $@, qr/^Reading sample.txt/, "correctly failed to read nonexistent file" );
@@ -140,7 +140,7 @@ sub create_test_file {
=head1 NAME
-07-open_file.t - test C<Parrot::Pmc2c::Utils::open_file()>
+07-open_file.t - test C<Parrot::Pmc2c::Pmc2cMain::open_file()>
=head1 SYNOPSIS
@@ -149,11 +149,11 @@ sub create_test_file {
=head1 DESCRIPTION
The files in this directory test the publicly callable methods of
-F<lib/Parrot/Pmc2c/Utils.pm>. By doing so, they test the functionality
+F<lib/Parrot/Pmc2c/Pmc2cMain.pm>. By doing so, they test the functionality
of the F<pmc2c.pl> utility. That functionality has largely been extracted
-into the methods of F<Utils.pm>.
+into the methods of F<Pmc2cMain.pm>.
-F<07-open_file.t> tests the C<Parrot::Pmc2c::Utils::open_file()> subroutine.
+F<07-open_file.t> tests the C<Parrot::Pmc2c::Pmc2cMain::open_file()> subroutine.
This subroutine is I<not> called F<make> but is called by methods which are
called by F<make>.
View
4 t/tools/pmc2cutils/README
@@ -2,7 +2,7 @@
# $Id$
README for directory t/tools/pmc2cutils/
-This directory contains test code for Parrot::Pmc2c::Utils, a Perl5
+This directory contains test code for Parrot::Pmc2c::Pmc2cMain, a Perl5
module whose publicly callable methods and other subroutines supply
functionality for Parrot build tool 'pmc2c.pl'.
@@ -15,7 +15,7 @@ that point in the build process, but some will necessarily fail
if 'make' has already been executed. Hence, they should not be
included in the set of tests run by 'make test'.
-In short, these are tests of Parrot::Pmc2c::Utils but are *not*
+In short, these are tests of Parrot::Pmc2c::Pmc2cMain but are *not*
tests of Parrot itself.
View
229 tools/build/pmc2c.pl
@@ -9,22 +9,24 @@
use lib "$FindBin::Bin/../../lib";
use Getopt::Long;
use Data::Dumper;
-use Parrot::Pmc2c::Utils;
+use Parrot::Pmc2c::Pmc2cMain;
-my ( %opt, @include );
-my %action;
+my ( %action, %options, @pmc_include_paths );
GetOptions(
- "include=s" => \@include,
+ #pmc include paths
+ "include=s" => \@pmc_include_paths,
+ #program actions
"vtable" => \$action{default},
"dump" => \$action{dump},
"c|gen-c" => \$action{gen_c},
"tree" => \$action{tree},
- "no-lines" => \$opt{nolines},
- "debug+" => \$opt{debug},
- "verbose+" => \$opt{verbose},
- "library=s" => \$opt{library},
- "testing" => \$opt{testing},
+ #command line options
+ "no-lines" => \$options{nolines},
+ "debug+" => \$options{debug},
+ "verbose+" => \$options{verbose},
+ "library=s" => \$options{library},
+ "testing" => \$options{testing},
) or exit 1;
if ( 0 == grep { $action{$_} } keys %action ) {
@@ -33,16 +35,16 @@
my @args = @ARGV;
-my $self = Parrot::Pmc2c::Utils->new(
+my $self = Parrot::Pmc2c::Pmc2cMain->new(
{
- include => \@include,
- opt => \%opt,
+ include => \@pmc_include_paths,
+ opt => \%options,
args => \@args,
}
);
if ( $action{default} ) {
- my $dump_file = $self->dump_vtable("$FindBin::Bin/../../vtable.tbl");
+ $self->dump_vtable("$FindBin::Bin/../../vtable.tbl");
exit;
}
@@ -52,7 +54,7 @@
}
if ( $action{tree} ) {
- $self->print_tree( { depth => 0, } );