Perlito5

 view release on metacpan or  search on metacpan

lib/Perlito5/Runtime.pm  view on Meta::CPAN

package Perlito5;
use Perlito5::Grammar::Scope;
use strict;

our @PERL_VERSION = ( 5, 26, 0 );

$^O = 'perlito5'    unless defined $^O;
$/  = chr(10)       unless defined $/;
$"  = ' '           unless defined $";
$,  = undef         unless defined $,;
$!  = ''            unless defined $!;
$;  = chr(28)       unless defined $;;
$?  = 0             unless defined $?;
# $[  = 0             unless defined $[;    # "assignment to $[ is deprecated"
$]  = sprintf( "%d.%03d%03d", @PERL_VERSION )    unless $];      # $] is defined(), but ${"main::]"} is not
$^V = bless( { 'original' => 'v' . join( ".", @PERL_VERSION ),   # v5.26.0
               'qv'       => 1,
               'version'  => [ @PERL_VERSION ]
             }, 'version' )
                    unless defined $^V;
$^H = 0;
%^H = ();

our $EXPAND_USE   = 1;
our $EMIT_USE     = 0;
our $WARNINGS     = 0;
our $UTF8         = 0;
our $BYTES        = 0;
our @CALLER       = ();
our %DATA_SECTION = ();   # contents of the __DATA__ sections per package
our $PKG_NAME     = '';   # current package being compiled
our $LINE_NUMBER  = 0;    # current line number being compiled
our $FILE_NAME    = '';   # current file name being compiled
our %FORMAT       = ();   # 'format' statements - hash of subs

# information about the current compilation process
our $GLOBAL          = {};
our @BASE_SCOPE      = ( Perlito5::Grammar::Scope->new_base_scope() );
our $CLOSURE_SCOPE   = 0;    # variables that are in scope in the current closure being compiled
our @SCOPE_STMT      = ();
our @END_BLOCK       = ();    # END block LIFO - array of subs
our @INIT_BLOCK      = ();    # INIT block FIFO - array of subs
our @CHECK_BLOCK     = ();    # CHECK block LIFO - array of subs
our @UNITCHECK_BLOCK = ();    # UNITCHECK block LIFO - array of subs
our %BEGIN_SCRATCHPAD = ();   # list of "my" variables captured in BEGIN blocks
our $PROTO           = {};
our %VARS            = ();    # implements "use vars"

# $Perlito5::STRICT_* - See Perlito5X::strict.pm

# the Perl-to-Java compiler uses this syntax for "annotations":
#   package Put { import => 'java.Put' };
# annotations are stored as namespace + AST
our @ANNOTATION;

sub set_global_phase {
    my $phase = shift;
    local $@;
    eval { ${^GLOBAL_PHASE} = $phase };
}

our $ID           = 100;    # generic "id" source; increment after use

# list of packages that "exist" - this is used by the indirect-object parser
our $PACKAGES = {
    STDERR       => 1,
    STDOUT       => 1,
    STDIN        => 1,
    main         => 1,
    strict       => 1,
    warnings     => 1,
    utf8         => 1,
    bytes        => 1,
    encoding     => 1,
    UNIVERSAL    => 1,
    CORE         => 1,
    'CORE::GLOBAL' => 1,
    'Perlito5::IO' => 1,
};

push @INC, $_
    for split ":", ($ENV{PERL5LIB} || "");

# magic numbers - See lib/integer.pm in perl distribution
$Perlito5::INTEGER = 0x01;
# magic numbers - See lib/overloading.pm in perl distribution
$Perlito5::HINT_NO_AMAGIC = 0x01000000;

# these operators change when "use integer" - ( $^H & $Perlito5::INTEGER )
%Perlito5::Integer = (
    '%'   => 1,
    '>>'  => 1,
    '<<'  => 1,
    '^'   => 1,
    '&'   => 1,
    '|'   => 1,
    '+'   => 1,
    '-'   => 1,
    '*'   => 1,
    '/'   => 1,

    '%='  => 1,
    '>>=' => 1,
    '<<=' => 1,



( run in 1.441 second using v1.01-cache-2.11-cpan-5b529ec07f3 )