Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow EVALing Perl 6 code from Perl 5.
  • Loading branch information
niner committed Feb 7, 2015
1 parent 5902244 commit 35bf0a4
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/Inline/Perl5.pm6
Expand Up @@ -457,6 +457,13 @@ class Perl6PackageCreator {
}
}

class Perl6Evaluator {
has $.p5;
method run($code) {
return $!p5.p6_to_p5(EVAL $code);
}
}

method init_callbacks {
self.run(q[
package Perl6::Object;
Expand Down Expand Up @@ -487,9 +494,15 @@ method init_callbacks {
my $package;
my $creator;
my $evaluator;
sub init {
($creator) = @_;
($creator, $evaluator) = @_;
}
sub run {
my ($code) = @_;
return $evaluator->run($code);
}
sub import {
Expand All @@ -506,7 +519,7 @@ method init_callbacks {
1;
]);

self.call('v6::init', Perl6PackageCreator.new);
self.call('v6::init', Perl6PackageCreator.new, Perl6Evaluator.new(:p5(self)));

if $!external_p5 {
p5_inline_perl6_xs_init($!p5);
Expand Down

0 comments on commit 35bf0a4

Please sign in to comment.