Skip to content

Commit

Permalink
try to make the $_ for -n and -p "is copy"
Browse files Browse the repository at this point in the history
does not seem to work :(
  • Loading branch information
moritz committed Jan 12, 2012
1 parent 26f0b39 commit 4f3e5fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Perl6/Actions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ class Perl6::Actions is HLL::Actions {

# Turn $code into "for lines() { $code }"
sub wrap_option_n_code($/, $code) {
$code := make_topic_block_ref($code);
# TODO: apply 'is copy' trait
$code := make_topic_block_ref($code, copy => 1);
return PAST::Op.new(:name<&eager>,
PAST::Op.new(:pasttype<callmethod>, :name<map>,
PAST::Op.new( :name<&flat>,
Expand Down Expand Up @@ -4006,14 +4005,19 @@ class Perl6::Actions is HLL::Actions {
return $*W.create_code_object($block, $type, $sig);
}

sub make_topic_block_ref($past) {
sub make_topic_block_ref($past, :$copy) {
my $block := PAST::Block.new(
PAST::Stmts.new(
PAST::Var.new( :name('$_'), :scope('lexical_6model'), :isdecl(1) )
),
$past);
($*W.cur_lexpad())[0].push($block);
my $param := hash( :variable_name('$_'), :nominal_type($*W.find_symbol(['Mu'])), :is_parcel(1) );
my $param := hash( :variable_name('$_'), :nominal_type($*W.find_symbol(['Mu'])));
if $copy {
$param<is_copy> := 1;
} else {
$param<is_parcel> := 1;
}
my $sig := $*W.create_signature([$*W.create_parameter($param)]);
add_signature_binding_code($block, $sig, [$param]);
return reference_to_code_object(
Expand Down
3 changes: 3 additions & 0 deletions src/Perl6/World.pm
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,9 @@ class Perl6::World is HLL::World {
if %param_info<is_multi_invocant> {
$flags := $flags + $SIG_ELEM_MULTI_INVOCANT;
}
if %param_info<is_copy> {
$flags := $flags + $SIG_ELEM_IS_COPY;
}
if %param_info<is_parcel> {
$flags := $flags + $SIG_ELEM_IS_PARCEL;
}
Expand Down

0 comments on commit 4f3e5fc

Please sign in to comment.