Ticket #918: class_init.patch
File class_init.patch, 1.9 KB (added by NotFound, 12 years ago) |
---|
-
lib/Parrot/Pmc2c/PMCEmitter.pm
96 96 $c->emit( $self->get_vtable_func ); 97 97 $c->emit( $self->get_mro_func ); 98 98 $c->emit( $self->get_isa_func ); 99 $c->emit( $self->pmc_class_init_func ); 99 100 $c->emit( $self->init_func ); 100 101 $c->emit( $self->postamble ); 101 102 … … 479 480 return $cache->{$name} = "mfl_$count"; 480 481 } 481 482 483 =item C<pmc_class_init_func()> 484 485 Returns the C code for the PMC's class_init function as a static 486 function to be called from the exported class_init. 487 488 =cut 489 490 sub pmc_class_init_func { 491 my ($self) = @_; 492 my $class_init_code = ""; 493 494 if ($self->has_method('class_init')) { 495 $class_init_code .= $self->get_method('class_init')->body; 496 497 $class_init_code =~ s/INTERP/interp/g; 498 499 # fix indenting 500 $class_init_code =~ s/^/ /mg; 501 $class_init_code = <<ENDOFCODE 502 static void thispmc_class_init(PARROT_INTERP, int entry) 503 { 504 $class_init_code 505 } 506 ENDOFCODE 507 } 508 return $class_init_code; 509 } 510 482 511 =item C<init_func()> 483 512 484 513 Returns the C code for the PMC's initialization method, or an empty … … 533 562 my $class_init_code = ""; 534 563 535 564 if ($self->has_method('class_init')) { 536 $class_init_code = $self->get_method('class_init')->body; 537 538 $class_init_code =~ s/INTERP/interp/g; 539 540 # fix indenting 541 $class_init_code =~ s/^/ /mg; 565 $class_init_code .= " thispmc_class_init(interp, entry);\n"; 542 566 } 543 567 544 568 my %extra_vt; … … 715 739 # include any class specific init code from the .pmc file 716 740 if ($class_init_code) { 717 741 $cout .= <<"EOC"; 742 718 743 /* class_init */ 719 {720 744 $class_init_code 721 } 745 722 746 EOC 723 747 } 724 748