Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix Pod::Block::Declarator ordering. Reveals an ugly GC bug
  • Loading branch information
Tadeusz Sośnierz committed Aug 8, 2011
1 parent c1fdc43 commit 396201b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Pod/To/Text.pm
Expand Up @@ -53,7 +53,7 @@ sub declarator2text($pod) {
when nqp::p6bool(nqp::istype($_.HOW, Metamodel::ModuleHOW)) {
'module'
}
} ~ ' ' ~ $pod.WHEREFORE.perl ~ ': ' ~ $pod.WHEREFORE.WHY ~ "\n"
} ~ ' ' ~ $pod.WHEREFORE.perl ~ ': ' ~ $pod.WHEREFORE.WHY.content ~ "\n"
}

# vim: ft=perl6
32 changes: 28 additions & 4 deletions src/Perl6/Grammar.pm
@@ -1,6 +1,7 @@
use NQPP6Regex;
use QRegex;
use Perl6::SymbolTable;
use Perl6::Pod;

grammar Perl6::Grammar is HLL::Grammar {
method TOP() {
Expand Down Expand Up @@ -144,6 +145,24 @@ grammar Perl6::Grammar is HLL::Grammar {
{ $*DECLARATOR_DOCS := ~$<attachment> }
}

token attach_docs {
{
$*DECLARATOR_DOCS := '';
if $*DOC ne '' {
my $cont := Perl6::Pod::serialize_aos(
[$*DOC]
)<compile_time_value>;
my $block := $*ST.add_constant(
'Pod::Block::Declarator', 'type_new',
:nocache, :content($cont),
);
$*DOCEE := $block<compile_time_value>;
$*POD_BLOCKS.push($*DOCEE);
}
}
<?>
}

token pod_content_toplevel {
<pod_block>
}
Expand Down Expand Up @@ -1051,7 +1070,8 @@ grammar Perl6::Grammar is HLL::Grammar {
:my $*IN_DECL := 'package';
:my $*CURPAD;
:my $*DOC := $*DECLARATOR_DOCS;
{ $*DECLARATOR_DOCS := '' }
:my $*DOCEE;
<.attach_docs>

# Meta-object will live in here; also set default REPR (a trait
# may override this, e.g. is repr('...')).
Expand Down Expand Up @@ -1215,8 +1235,10 @@ grammar Perl6::Grammar is HLL::Grammar {

rule scoped($*SCOPE) {<.end_keyword> [
:my $*TYPENAME := '';

:my $*DOC := $*DECLARATOR_DOCS;
{ $*DECLARATOR_DOCS := '' }
:my $*DOCEE;
<.attach_docs>
[
| <DECL=variable_declarator>
| <DECL=routine_declarator>
Expand Down Expand Up @@ -1271,7 +1293,8 @@ grammar Perl6::Grammar is HLL::Grammar {
:my $*IN_DECL := $d;
:my $*METHODTYPE;
:my $*DOC := $*DECLARATOR_DOCS;
{ $*DECLARATOR_DOCS := '' }
:my $*DOCEE;
<.attach_docs>
<deflongname>?
<.newpad>
[ '(' <multisig> ')' ]?
Expand All @@ -1287,7 +1310,8 @@ grammar Perl6::Grammar is HLL::Grammar {
:my $*IN_DECL := $d;
:my $*METHODTYPE := $d;
:my $*DOC := $*DECLARATOR_DOCS;
{ $*DECLARATOR_DOCS := '' }
:my $*DOCEE;
<.attach_docs>
[
<.newpad>
[
Expand Down
12 changes: 1 addition & 11 deletions src/Perl6/Pod.pm
Expand Up @@ -3,17 +3,7 @@ class Perl6::Pod {
our sub document($what, $with) {
if $with ne '' {
my $true := $*ST.add_constant('Int', 'int', 1)<compile_time_value>;
my $doc := $*ST.add_constant('Str', 'str', $with)<compile_time_value>;
$*ST.apply_trait('&trait_mod:<is>', $what, $doc, :docs($true));

# add it to $=POD
my $cont := serialize_array([$doc])<compile_time_value>;
my $block := $*ST.add_constant(
'Pod::Block::Declarator', 'type_new',
:nocache,
:WHEREFORE($what), :content($cont),
);
$*POD_BLOCKS.push($block<compile_time_value>);
$*ST.apply_trait('&trait_mod:<is>', $what, $*DOCEE, :docs($true));
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/core/Pod.pm
Expand Up @@ -18,6 +18,9 @@ my package Pod {

class Block::Declarator is Block {
has $.WHEREFORE;
method set_docee($d) {
$!WHEREFORE = $d
}
}

class Block::Table is Block {
Expand Down
2 changes: 2 additions & 0 deletions src/core/traits.pm
Expand Up @@ -61,10 +61,12 @@ multi trait_mod:<is>(Mu:D $docee, $doc, :$docs!) {
method set_docs($d) { $!WHY = $d }
}
$docee.set_docs($doc);
$doc.set_docee($docee);
}

multi trait_mod:<is>(Mu:U $docee, $doc, :$docs!) {
$docee.HOW.set_docs($doc);
$doc.set_docee($docee);
}


Expand Down
2 changes: 1 addition & 1 deletion tools/build/Makefile.in
Expand Up @@ -299,7 +299,7 @@ $(PERL6_ST_PBC): $(NQP_EXE) $(PERL6_ML_PBC) src/Perl6/SymbolTable.pm
src/Perl6/SymbolTable.pm
$(PARROT) $(PARROT_ARGS) -o $(PERL6_ST_PBC) $(PERL6_ST)

$(PERL6_G_PBC): $(NQP_EXE) $(PERL6_ST_PBC) src/Perl6/Grammar.pm
$(PERL6_G_PBC): $(NQP_EXE) $(PERL6_ST_PBC) src/Perl6/Grammar.pm $(PERL6_P_PBC)
$(NQP_EXE) --target=pir --output=$(PERL6_G) --encoding=utf8 \
src/Perl6/Grammar.pm
$(PARROT) $(PARROT_ARGS) -o $(PERL6_G_PBC) $(PERL6_G)
Expand Down

0 comments on commit 396201b

Please sign in to comment.