[svn:parrot] r43608 - branches/tt389_fix/lib/Parrot/Pmc2c
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Tue Jan 26 20:48:05 UTC 2010
Author: chromatic
Date: Tue Jan 26 20:48:02 2010
New Revision: 43608
URL: https://trac.parrot.org/parrot/changeset/43608
Log:
[lib] Extracted write_nci_methods() method from init_func() method in PMC
emitter. This will help subsequent changes.
Modified:
branches/tt389_fix/lib/Parrot/Pmc2c/PMCEmitter.pm
Modified: branches/tt389_fix/lib/Parrot/Pmc2c/PMCEmitter.pm
==============================================================================
--- branches/tt389_fix/lib/Parrot/Pmc2c/PMCEmitter.pm Tue Jan 26 19:52:49 2010 (r43607)
+++ branches/tt389_fix/lib/Parrot/Pmc2c/PMCEmitter.pm Tue Jan 26 20:48:02 2010 (r43608)
@@ -682,23 +682,7 @@
Parrot_create_mro(interp, entry);
EOC
- # declare each nci method for this class
- foreach my $method ( @{ $self->{methods} } ) {
- next unless $method->type eq Parrot::Pmc2c::Method::NON_VTABLE;
-
- #these differ for METHODs
- my $method_name = $method->name;
- my $symbol_name = $method->symbol;
-
- $cout .= <<"EOC";
- register_raw_nci_method_in_ns(interp, entry, F2DPTR(Parrot_${classname}_${method_name}), CONST_STRING_GEN(interp, "$symbol_name"));
-EOC
- if ( $method->{attrs}{write} ) {
- $cout .= <<"EOC";
- Parrot_mark_method_writes(interp, entry, "$symbol_name");
-EOC
- }
- }
+ $cout .= $self->write_nci_methods();
# include any class specific init code from the .pmc file
if ($class_init_code) {
@@ -740,6 +724,38 @@
$cout;
}
+=item C<write_nci_methods()>
+
+Returns the C code to register any NCI methods for the PMC.
+
+=cut
+
+sub write_nci_methods {
+ my $self = shift;
+ my $cout = '';
+ my $classname = $self->name;
+
+ # declare each nci method for this class
+ for my $method ( @{ $self->{methods} } ) {
+ next unless $method->type eq Parrot::Pmc2c::Method::NON_VTABLE;
+
+ #these differ for METHODs
+ my $method_name = $method->name;
+ my $symbol_name = $method->symbol;
+
+ $cout .= <<"EOC";
+ register_raw_nci_method_in_ns(interp, entry, F2DPTR(Parrot_${classname}_${method_name}), CONST_STRING_GEN(interp, "$symbol_name"));
+EOC
+ if ( $method->{attrs}{write} ) {
+ $cout .= <<"EOC";
+ Parrot_mark_method_writes(interp, entry, "$symbol_name");
+EOC
+ }
+ }
+
+ return $cout;
+}
+
=item C<update_vtable_func()>
Returns the C code for the PMC's update_vtable method.
More information about the parrot-commits
mailing list