Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
WhateverCode type implemented
  • Loading branch information
Vyacheslav Matjukhin authored and jnthn committed Jun 21, 2010
1 parent c6a829d commit 00efa15
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions build/Makefile.in
Expand Up @@ -213,6 +213,7 @@ CORE_SOURCES = \
src/core/Parameter.pm \
src/core/Signature.pm \
src/core/Block.pm \
src/core/WhateverCode.pm \
src/core/Routine.pm \
src/core/Regex.pm \
src/core/Junction.pm \
Expand Down
10 changes: 5 additions & 5 deletions src/Perl6/Actions.pm
Expand Up @@ -3090,39 +3090,39 @@ sub whatever_curry($past, $upto_arity) {
my $sig := Perl6::Compiler::Signature.new(
Perl6::Compiler::Parameter.new(:var_name('$x')),
Perl6::Compiler::Parameter.new(:var_name('$y')));
$past := make_block_from($sig, $past);
$past := make_block_from($sig, $past, 'WhateverCode');
}
elsif $upto_arity == 2 && $past[1] ~~ PAST::Op && $past[1].returns eq 'Whatever' {
# Curry right arg.
$past.pop;
$past.push(PAST::Var.new( :name('$y'), :scope('lexical') ));
my $sig := Perl6::Compiler::Signature.new(
Perl6::Compiler::Parameter.new(:var_name('$y')));
$past := make_block_from($sig, $past);
$past := make_block_from($sig, $past, 'WhateverCode');
}
elsif $upto_arity >= 1 && $past[0] ~~ PAST::Op && $past[0].returns eq 'Whatever' {
# Curry left (or for unary, only) arg.
$past.shift;
$past.unshift(PAST::Var.new( :name('$x'), :scope('lexical') ));
my $sig := Perl6::Compiler::Signature.new(
Perl6::Compiler::Parameter.new(:var_name('$x')));
$past := make_block_from($sig, $past);
$past := make_block_from($sig, $past, 'WhateverCode');
}
}
$past
}

# Helper for constructing a simple Perl 6 Block with the given signature
# and body.
sub make_block_from($sig, $body) {
sub make_block_from($sig, $body, $type = 'Block') {
my $past := PAST::Block.new( :blocktype('declaration'),
PAST::Stmts.new( ),
PAST::Stmts.new(
$body
)
);
my $lazy_name := add_signature($past, $sig, 1);
create_code_object($past, 'Block', 0, $lazy_name);
create_code_object($past, $type, 0, $lazy_name);
}

# vim: ft=perl6
3 changes: 3 additions & 0 deletions src/core/WhateverCode.pm
@@ -0,0 +1,3 @@
class WhateverCode is Block {}

# vim: ft=perl6

0 comments on commit 00efa15

Please sign in to comment.