Skip to content

Commit

Permalink
Refactor PL/Perl6 wrapper code
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Jul 30, 2010
1 parent 7b9d02d commit 193bf38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plparrot.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ plperl6_call_handler(PG_FUNCTION_ARGS)
{
Datum retval = 0;
TriggerData *tdata;
elog(NOTICE, "plperl6_call_handler");
//debug("plperl6_call_handler");
interp = p6_interp;
if(!interp) {
elog(ERROR,"Invalid Parrot interpreter for PL/Perl6!");
Expand Down
16 changes: 10 additions & 6 deletions plperl6.pir
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.sub run
.param string code
.param pmc args :slurpy
args = convert_to_perl6_array(args)
args = convert_to_perl6_parcel(args)
$S0 = "eval q<<< sub (@_) {"
$S1 = "} >>>"
code = $S0 . code
Expand All @@ -21,13 +21,17 @@
.return($P3)
.end

.sub convert_to_perl6_array
.sub convert_to_perl6_parcel
.param pmc parrot_array
.local pmc arrayizer
.local pmc arrayizer, perl6_parcel

# the infix comma operator, which creates Parcels from scalars
arrayizer = get_root_global ['perl6'], '&infix:<,>'
unless arrayizer goto error
$P0 = arrayizer(parrot_array :flat)
.return($P0)

# pass a flattened array to the comma operator
perl6_parcel = arrayizer(parrot_array :flat)
.return(perl6_parcel)
error:
die "Could not turn Parrot array into a Perl 6 array!"
die "Could not turn Parrot array into a Perl 6 Parcel!"
.end

0 comments on commit 193bf38

Please sign in to comment.