[svn:parrot] r39522 - in trunk: lib/Parrot/Pmc2c src/pmc
cotto at svn.parrot.org
cotto at svn.parrot.org
Fri Jun 12 08:42:12 UTC 2009
Author: cotto
Date: Fri Jun 12 08:42:10 2009
New Revision: 39522
URL: https://trac.parrot.org/parrot/changeset/39522
Log:
[pmc2c] make some special-case code the common case
Simply deleting the code from PMCEmitter.pm causes no test failures, but this may result from poor thread test coverage.
Modified:
trunk/lib/Parrot/Pmc2c/PMCEmitter.pm
trunk/src/pmc/default.pmc
Modified: trunk/lib/Parrot/Pmc2c/PMCEmitter.pm
==============================================================================
--- trunk/lib/Parrot/Pmc2c/PMCEmitter.pm Fri Jun 12 07:51:40 2009 (r39521)
+++ trunk/lib/Parrot/Pmc2c/PMCEmitter.pm Fri Jun 12 08:42:10 2009 (r39522)
@@ -207,8 +207,6 @@
sub init {
my ($self) = @_;
- $self->fixup_singleton if $self->singleton;
-
#!( singleton or abstract ) everything else gets readonly version of
# methods too.
@@ -216,38 +214,6 @@
unless $self->abstract or $self->singleton;
}
-sub fixup_singleton {
- my ($self) = @_;
-
- # Because singletons are shared between interpreters, we need to make
- # special effort to use the right namespace for method lookups.
- #
- # Note that this trick won't work if the singleton inherits from something
- # else (because the MRO will still be shared).
-
- unless ( $self->implements_vtable('get_namespace')
- or $self->super_method('get_namespace') ne 'default' )
- {
- my $body =
- Parrot::Pmc2c::Emitter->text(
- " return INTERP->vtables[SELF->vtable->base_type]->_namespace;\n");
- $self->add_method(
- Parrot::Pmc2c::Method->new(
- {
- name => 'get_namespace',
- parent_name => $self->name,
- parameters => '',
- body => $body,
- type => Parrot::Pmc2c::Method::VTABLE,
- mmds => [],
- return_type => 'PMC*',
- attrs => {},
- }
- )
- );
- }
-}
-
=item C<gen_includes()>
Returns the C C<#include> for the header file of each of the PMC's superclasses.
Modified: trunk/src/pmc/default.pmc
==============================================================================
--- trunk/src/pmc/default.pmc Fri Jun 12 07:51:40 2009 (r39521)
+++ trunk/src/pmc/default.pmc Fri Jun 12 08:42:10 2009 (r39522)
@@ -494,7 +494,16 @@
*/
VTABLE PMC *get_namespace() {
- return SELF->vtable->_namespace;
+
+ /* Because singletons are shared between interpreters, we need to make
+ * special effort to use the right namespace for method lookups.
+ * Note that this trick won't work if the singleton inherits from
+ * something else (because the MRO will still be shared).
+ * Having this code here avoids creating a special case for singletons
+ * elsewhere.
+ */
+
+ return INTERP->vtables[SELF->vtable->base_type]->_namespace;
}
More information about the parrot-commits
mailing list