Skip to content

Commit

Permalink
Convert Parrot arrays to Perl 6 arrays, moritz++
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Jul 28, 2010
1 parent 29a86df commit d80522c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions plperl6.pir
@@ -1,8 +1,9 @@
.sub run
.param string code
.param pmc args :slurpy
$S0 = "my $r = eval q<<<\nsub {"
$S1 = "}\n>>>; $r.()"
args = convert_to_perl6_array(args)
$S0 = "my $r = eval q<<< sub {"
$S1 = "} >>>; $r.()"
code = $S0 . code
code .= $S1
load_bytecode 'dumper.pbc'
Expand All @@ -15,5 +16,17 @@
$P2 = $P1(args)
print "code returned: "
_dumper($P2)
say "=============="
.return($P2)
.end

.sub convert_to_perl6_array
.param pmc parrot_array
.local pmc arrayizer
arrayizer = get_root_global ['perl6'], '&infix:<,>'
unless arrayizer goto error
$P0 = arrayizer(parrot_array :flat)
.return($P0)
error:
die "Could not turn Parrot array into a Perl 6 array!"
.end
1 change: 1 addition & 0 deletions t/sql/plperl6.sql
Expand Up @@ -26,6 +26,7 @@ CREATE FUNCTION test_int_plperl6(integer) RETURNS int LANGUAGE plperl6 AS $$
$$;

CREATE FUNCTION test_arguments_plperl6(integer) RETURNS int LANGUAGE plperl6 AS $$
say '@_ = ', @_;
@_[0]
$$;

Expand Down

0 comments on commit d80522c

Please sign in to comment.