Skip to content

Commit

Permalink
Merge branch 'ng' of git@github.com:rakudo/rakudo into ng
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Feb 7, 2010
2 parents b65c299 + 245ca14 commit b652882
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
14 changes: 14 additions & 0 deletions src/Perl6/Actions.pm
Expand Up @@ -170,7 +170,13 @@ method pblock($/) {
}
}
}
if $<lambda> eq '<->' {
$signature.set_rw_by_default();
}
add_signature($block, $signature, 0);
if $<lambda> {
prevent_null_return($block);
}
make $block;
}

Expand Down Expand Up @@ -2161,3 +2167,11 @@ sub is_attr_alias($name) {
}
return "";
}

# Gives a block a Nil to return if it has no statements, to prevent Null
# PMCs being handed back.
sub prevent_null_return($block) {
if +@($block[1]) == 0 {
$block[1].push(PAST::Op.new( :name('&Nil') ));
}
}
26 changes: 9 additions & 17 deletions src/Perl6/Compiler/Signature.pm
Expand Up @@ -150,6 +150,15 @@ method get_declarations() {
}


# Sets all parameters without an explicit read type to default to rw.
method set_rw_by_default() {
my @entries := self.entries;
for @entries {
$_.is_rw(1);
}
}


# Produces an AST for generating a low-level signature object. Optionally can
# instead produce code to generate a high-level signature object.
method ast($high_level?) {
Expand Down Expand Up @@ -337,23 +346,6 @@ method entries() {
$!entries
}
#############################################################################
####################### CODE TO RE-WRITE IN NG BRANCH #######################
#############################################################################
# Sets all parameters without an explicit read type to default to rw.
method set_rw_by_default() {
my @entries := self.entries;
for @entries {
unless $_<read_type> {
$_<read_type> := 'rw';
}
}
}


# Local Variables:
# mode: cperl
# cperl-indent-level: 4
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/Grammar.pm
Expand Up @@ -273,7 +273,7 @@ token xblock($*IMPLICIT = 0) {
}

token pblock($*IMPLICIT = 0) {
| <.lambda>
| <lambda>
<.newpad>
:my $*SCOPE := 'my';
<signature>
Expand Down
2 changes: 1 addition & 1 deletion t/spectest.data
Expand Up @@ -177,7 +177,7 @@ S03-operators/subscript-vs-lt.t
S03-operators/so.t
# S03-operators/value_equivalence.t
# S04-blocks-and-statements/pointy-rw.t
# S04-blocks-and-statements/pointy.t
S04-blocks-and-statements/pointy.t
S04-phasers/end.t
# S04-phasers/start.t
# S04-declarations/constant.t
Expand Down

0 comments on commit b652882

Please sign in to comment.