| 1 | package Perlito5::Perl5::Runtime; | ||
| 2 | |||
| 3 | sub eval_ast { | ||
| 4 | my ($ast) = @_; | ||
| 5 | my $want = 0; | ||
| 6 | |||
| 7 | my @data = $ast->emit_perl5(0, $want); | ||
| 8 | my $out = []; | ||
| 9 | Perlito5::Perl5::PrettyPrinter::pretty_print( \@data, 0, $out ); | ||
| 10 | my $code = "package $Perlito5::PKG_NAME; " . join( '', @$out ) . "\n"; | ||
| 11 | # say STDERR "source: [" . $code . "]"; | ||
| 12 | Perlito5::set_global_phase("UNITCHECK"); | ||
| 13 | $_->() while $_ = shift @Perlito5::UNITCHECK_BLOCK; | ||
| 14 | $code = "#line $Perlito5::LINE_NUMBER \"$Perlito5::FILE_NAME\"\n" . $code; | ||
| 15 | return eval($code); | ||
| 16 | } | ||
| 17 | |||
| 18 | sub emit_perl5 { | ||
| 19 | return <<'EOT'; | ||
| 20 | |||
| 21 | use v5.10; | ||
| 22 | use feature 'say'; | ||
| 23 | |||
| 24 | EOT | ||
| 25 | } | ||
| 26 | |||
| 27 | 1; | ||
| 28 | |||
| 29 | =pod | ||
| 30 | |||
| 31 | =head1 NAME | ||
| 32 | |||
| 33 | Perlito5::Perl5::Runtime | ||
| 34 | |||
| 35 | =head1 DESCRIPTION | ||
| 36 | |||
| 37 | Provides runtime routines for the Perlito-in-Perl5 compiled code | ||
| 38 | |||
| 39 | =head1 AUTHORS | ||
| 40 | |||
| 41 | The Pugs Team. | ||
| 42 | |||
| 43 | =head1 COPYRIGHT | ||
| 44 | |||
| 45 | Copyright 2006, 2009, 2011, 2012 by Flavio Soibelmann Glock and others. | ||
| 46 | |||
| 47 | This program is free software; you can redistribute it and/or modify it | ||
| 48 | under the same terms as Perl itself. | ||
| 49 | |||
| 50 | See L<http://www.perl.com/perl/misc/Artistic.html> | ||
| 51 | |||
| 52 | =cut |