/
pmc2c.pl
138 lines (95 loc) · 2.73 KB
/
pmc2c.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#! perl
# Copyright (C) 2001-2006, The Perl Foundation.
# $Id$
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../..";
use lib "$FindBin::Bin/../../lib";
use Getopt::Long;
use Data::Dumper;
use Parrot::Pmc2c::Pmc2cMain;
my ( %action, %options, @pmc_include_paths );
GetOptions(
#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},
#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 ) {
die "No action specified!\n";
}
my @args = @ARGV;
my $self = Parrot::Pmc2c::Pmc2cMain->new(
{
include => \@pmc_include_paths,
opt => \%options,
args => \@args,
}
);
if ( $action{default} ) {
$self->dump_vtable("$FindBin::Bin/../../vtable.tbl");
exit;
}
if ( $action{dump} ) {
$self->dump_pmc();
exit;
}
if ( $action{tree} ) {
$self->print_tree();
exit;
}
if ( $action{gen_c} ) {
$self->gen_c();
exit;
}
=head1 NAME
tools/build/pmc2c.pl - PMC definition to C compiler
=head1 SYNOPSIS
=head2 Options used in Parrot F<Makefile>
Create F<src/pmc/foo.dump>:
% perl tools/build/pmc2c.pl --dump src/pmc/foo.pmc ...
Create F<vtable.dump>:
% perl tools/build/pmc2c.pl --vtable
Create F<src/pmc/foo.c> and C<pmc_foo.h> from F<src/pmc/foo.dump>:
% perl tools/build/pmc2c.pl -c src/pmc/foo.pmc ...
=head2 Other Options
Print a class tree for the specified PMCs:
% perl tools/build/pmc2c.pl --tree src/pmc/*.pmc
Create fooX.c and pmc_fooX.h from fooX.dump files, also create libfoo.c
containing the initialization function for all fooX PMCs.
% perl tools/build/pmc2c.pl --library libfoo -c \
src/pmc/foo1.pmc src/pmc/foo2.pmc ...
=head1 DESCRIPTION
The job of the PMC compiler is to take .pmc files and create C files
that can be compiled for use with the Parrot interpreter.
=head1 COMMAND-LINE OPTIONS
=over 4
=item C<--debug>
Increase debug level
=item C<--verbose>
Increase verbose level
=item C<--no-lines>
Omit source line info
=item C<--include=/path/to/pmc>
Specify include path where to find PMCs.
=item C<--library=libname>
Specify the library name. This will create F<E<lt>libnameE<gt>.c> and
F<pmc_E<lt>libnameE<gt>.h>. The initialization function will be named
after libname and will initialize all PMCs in the library.
=back
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: