cvsuser 04/11/11 04:35:54
Modified: lib/Parrot Pmc2c.pm
Log:
Current line number and name of output file need to be passed through to all
the body methods
Revision Changes Path
1.56 +57 -38 parrot/lib/Parrot/Pmc2c.pm
Index: Pmc2c.pm
===================================================================
RCS file: /cvs/public/parrot/lib/Parrot/Pmc2c.pm,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- Pmc2c.pm 11 Nov 2004 12:02:12 -0000 1.55
+++ Pmc2c.pm 11 Nov 2004 12:35:54 -0000 1.56
@@ -1,5 +1,5 @@
# Copyright: 2004 The Perl Foundation. All Rights Reserved.
-# $Id: Pmc2c.pm,v 1.55 2004/11/11 12:02:12 nicholas Exp $
+# $Id: Pmc2c.pm,v 1.56 2004/11/11 12:35:54 nicholas Exp $
=head1 NAME
@@ -541,15 +541,17 @@
return $_;
}
-=item C<body($method)>
+=item C<body($method, $line, $out_name)>
-Returns the C code for the method body.
+Returns the C code for the method body. C<$line> is used to accumulate
+the number of lines, C<$out_name> is the name of the output file we are
+generating.
=cut
sub body
{
- my ($self, $method) = @_;
+ my ($self, $method, $line, $out_name) = @_;
my $cout = "";
my $classname = $self->{class};
my $meth = $method->{meth};
@@ -603,15 +605,16 @@
$cout .= "\n\n";
}
-=item C<methods($line)>
+=item C<methods($line, $out_name)>
Returns the C code for the vtable methods. C<$line> is used to accumulate
-the number of lines.
+the number of lines, C<$out_name> is the name of the output file we are
+generating.
=cut
-sub methods() {
- my ($self, $line) = @_;
+sub methods {
+ my ($self, $line, $out_name) = @_;
my $cout = "";
# vtable methods
@@ -619,7 +622,7 @@
my $meth = $method->{meth};
next if $meth eq 'class_init';
if ($self->implements($meth)) {
- my $ret = $self->body($method, $line);
+ my $ret = $self->body($method, $line, $out_name);
$line += count_newlines($ret);
$cout .= $ret;
}
@@ -628,7 +631,7 @@
# nci methods
foreach my $method (@{ $self->{methods}} ) {
next unless $method->{loc} eq 'nci';
- my $ret = $self->body($method, $line);
+ my $ret = $self->body($method, $line, $out_name);
$line += count_newlines($ret);
$cout .= $ret;
}
@@ -924,10 +927,10 @@
$cout .= $self->line_directive_here($cout, $out_name)
. $self->includes;
my $l = count_newlines($cout);
- $cout .= $self->methods($l);
+ $cout .= $self->methods($l, $out_name);
$cout .= $self->init_func;
if ($self->{const}) {
- $cout .= $self->{const}->methods($l);
+ $cout .= $self->{const}->methods($l, $out_name);
$cout .= $self->{const}->init_func;
}
$cout .= $self->{post};
@@ -1023,15 +1026,17 @@
package Parrot::Pmc2c::Standard;
use base 'Parrot::Pmc2c';
-=item C<body($method)>
+=item C<body($method, $line, $out_name)>
-Returns the C code for the method body.
+Returns the C code for the method body. C<$line> is used to accumulate
+the number of lines, C<$out_name> is the name of the output file we are
+generating.
=cut
sub body
{
- my ($self, $method) = @_;
+ my ($self, $method, $line, $out_name) = @_;
my $meth = $method->{meth};
my $n = $self->{has_method}{$meth};
return $self->SUPER::body($self->{methods}[$n]);
@@ -1051,15 +1056,17 @@
use base 'Parrot::Pmc2c::Standard';
import Parrot::Pmc2c qw( gen_ret );
-=item C<body($method)>
+=item C<body($method, $line, $out_name)>
-Overrides the default implementation to throw exception if the method
-writes.
+Returns the C code for the method body. C<$line> is used to accumulate
+the number of lines, C<$out_name> is the name of the output file we are
+generating.
=cut
-sub body {
- my ($self, $method) = @_;
+sub body
+{
+ my ($self, $method, $line, $out_name) = @_;
my $meth = $method->{meth};
my $decl = $self->decl($self->{class}, $method, 0);
@@ -1115,9 +1122,11 @@
1;
}
-=item C<body($method, $line)>
+=item C<body($method, $line, $out_name)>
-Returns the C code for the method body.
+Returns the C code for the method body. C<$line> is used to accumulate
+the number of lines, C<$out_name> is the name of the output file we are
+generating.
Overrides the default implementation to direct all unknown methods to
the thing referred to.
@@ -1126,7 +1135,7 @@
sub body
{
- my ($self, $method, $line) = @_;
+ my ($self, $method, $line, $out_name) = @_;
my $meth = $method->{meth};
# existing methods get emitted
if ($self->SUPER::implements($meth)) {
@@ -1189,9 +1198,11 @@
return "ret_val = ";
}
-=item C<body($method, $line)>
+=item C<body($method, $line, $out_name)>
-Returns the C code for the method body.
+Returns the C code for the method body. C<$line> is used to accumulate
+the number of lines, C<$out_name> is the name of the output file we are
+generating.
Overrides the default implementation to perform locking.
@@ -1199,7 +1210,7 @@
sub body
{
- my ($self, $method, $line) = @_;
+ my ($self, $method, $line, $out_name) = @_;
my $meth = $method->{meth};
# existing methods get emitted
if ($self->SUPER::implements($meth)) {
@@ -1261,9 +1272,11 @@
1;
}
-=item C<body($method, $line)>
+=item C<body($method, $line, $out_name)>
-Returns the C code for the method body.
+Returns the C code for the method body. C<$line> is used to accumulate
+the number of lines, C<$out_name> is the name of the output file we are
+generating.
Overrides the default implementation to throw an execption for unknown
methods.
@@ -1272,7 +1285,7 @@
sub body
{
- my ($self, $method, $line) = @_;
+ my ($self, $method, $line, $out_name) = @_;
my $meth = $method->{meth};
# existing methods get emitted
if ($self->SUPER::implements($meth)) {
@@ -1320,9 +1333,11 @@
1;
}
-=item C<body($method, $line)>
+=item C<body($method, $line, $out_name)>
-Returns the C code for the method body.
+Returns the C code for the method body. C<$line> is used to accumulate
+the number of lines, C<$out_name> is the name of the output file we are
+generating.
The C<Null> PMC throws an execption for all methods.
@@ -1330,7 +1345,7 @@
sub body
{
- my ($self, $method, $line) = @_;
+ my ($self, $method, $line, $out_name) = @_;
my $meth = $method->{meth};
# existing methods get emitted
if ($self->SUPER::implements($meth)) {
@@ -1418,9 +1433,11 @@
return "ret_val = ($type) ";
}
-=item C<body($method, $line)>
+=item C<body($method, $line, $out_name)>
-Returns the C code for the method body.
+Returns the C code for the method body. C<$line> is used to accumulate
+the number of lines, C<$out_name> is the name of the output file we are
+generating.
The C<delegate> PMC redirects all methods to bytecode.
@@ -1428,7 +1445,7 @@
sub body
{
- my ($self, $method, $line) = @_;
+ my ($self, $method, $line, $out_name) = @_;
my $meth = $method->{meth};
# existing methods get emitted
if ($self->SUPER::implements($meth)) {
@@ -1490,9 +1507,11 @@
1;
}
-=item C<body($method, $line)>
+=item C<body($method, $line, $out_name)>
-Returns the C code for the method body.
+Returns the C code for the method body. C<$line> is used to accumulate
+the number of lines, C<$out_name> is the name of the output file we are
+generating.
Overrides the default implementation to direct all unknown methods to
the PMC in the first attribute slot.
@@ -1501,7 +1520,7 @@
sub body
{
- my ($self, $method, $line) = @_;
+ my ($self, $method, $line, $out_name) = @_;
my $meth = $method->{meth};
# existing methods get emitted
if ($self->SUPER::implements($meth)) {