From dd6a03a89c0f1f6bcf87e530ad137f1ca6d49001 Mon Sep 17 00:00:00 2001 From: pmichaud Date: Mon, 6 Sep 2010 16:25:55 -0500 Subject: [PATCH] Refactor whatever_curry to progress towards refactoring out create_code_object() in favor of block_closure() (which is the way all other closures are created). --- src/Perl6/Actions.pm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Perl6/Actions.pm b/src/Perl6/Actions.pm index 6109369cf42..5154fce0282 100644 --- a/src/Perl6/Actions.pm +++ b/src/Perl6/Actions.pm @@ -3006,7 +3006,7 @@ class Perl6::RegexActions is Regex::P6Regex::Actions { } # Takes a block and adds a signature to it, as well as code to bind the call -# capture against the signature. +# capture against the signature. Returns the modified block. sub add_signature($block, $sig_obj) { # Set arity. $block.arity($sig_obj.arity); @@ -3031,6 +3031,7 @@ sub add_signature($block, $sig_obj) { my $lazysig := PAST::Block.new(:blocktype, $sig_obj.ast(1)); $block[0].push($lazysig); $block := PAST::Val.new( :value($lazysig) ); + $block; } # Makes a lazy signature building block. @@ -3545,12 +3546,23 @@ sub whatever_curry($/, $past, $upto_arity) { $past.unshift($right_new); } $past.unshift($left_new); - $past := make_block_from($sig, $past, 'WhateverCode'); + $past := block_closure(blockify($past, $sig), 'WhateverCode', 0); + $past.returns('WhateverCode'); + $past.arity($sig.arity); } } $past } +sub blockify($past, $sig) { + add_signature( PAST::Block.new( :blocktype('declaration'), + PAST::Stmts.new( ), + PAST::Stmts.new( $past ) + ), + $sig + ); +} + # Helper for constructing a simple Perl 6 Block with the given signature # and body. sub make_block_from($sig, $body, $type = 'Block') {