Language-l33t

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

256 (so a memory byte can hold a value going from 0 to 255).


=back

=head2 source( $l33tcode )

Loads and "compiles" the string $l33tcode. If one program was already loaded,
it is clobbered by the newcomer. 

=head2 run( [ $nbr_iterations ] )

Runs the loaded program. If $nbr_iterations is given, interupts the program
after this number of iterations even if it hasn't terminated. Returns 0 in
case the program terminated by evaluating an END, 1 if it finished by reaching
$nbr_iterations.

=head2 reset

Reset the interpreter to its initial setting. Code is
recompiled, and pointers reset to their initial values. 

E.g.

    my $l33t = Language::l33t->new();
    $l33t->load( $code );

README.mkdn  view on Meta::CPAN

- byte\_size => $size

    The size of a byte in the memory used by the interpreter. Defaults to
    256 (so a memory byte can hold a value going from 0 to 255).

## source( $l33tcode )

Loads and "compiles" the string $l33tcode. If one program was already loaded,
it is clobbered by the newcomer. 

## run( \[ $nbr\_iterations \] )

Runs the loaded program. If $nbr\_iterations is given, interupts the program
after this number of iterations even if it hasn't terminated. Returns 0 in
case the program terminated by evaluating an END, 1 if it finished by reaching
$nbr\_iterations.

## reset

Reset the interpreter to its initial setting. Code is
recompiled, and pointers reset to their initial values. 

E.g.

```perl
my $l33t = Language::l33t->new();

lib/Language/l33t.pm  view on Meta::CPAN


has stdout => sub { return \*STDOUT;  };
has stdin  => ();
has socket => ();

before run => sub($self,@) {
    die "L0L!!1!1!! n0 l33t pr0gr4m l04d3d, sUxX0r!\n"
        unless $self->_has_memory;
};

sub run ( $self, $nbr_iterations = -1 ) {
  
    while ( $self->_iterate ) {
        $nbr_iterations-- if $nbr_iterations != -1;
        return 1 unless $nbr_iterations;
    }

    return 0;
}

sub _iterate($self) {
    my $op_id = $self->memory_cell( $self->op_ptr ); 
 
    if ( $self->debug ) { 
        no warnings qw/ uninitialized /;

lib/Language/l33t.pm  view on Meta::CPAN

The size of a byte in the memory used by the interpreter. Defaults to
256 (so a memory byte can hold a value going from 0 to 255).

=back

=head2 source( $l33tcode )

Loads and "compiles" the string $l33tcode. If one program was already loaded,
it is clobbered by the newcomer. 

=head2 run( [ $nbr_iterations ] )

Runs the loaded program. If $nbr_iterations is given, interupts the program
after this number of iterations even if it hasn't terminated. Returns 0 in
case the program terminated by evaluating an END, 1 if it finished by reaching
$nbr_iterations.

=head2 reset

Reset the interpreter to its initial setting. Code is
recompiled, and pointers reset to their initial values. 

E.g.

    my $l33t = Language::l33t->new();
    $l33t->load( $code );

lib/Language/l33t/Operators.pm  view on Meta::CPAN

    return 1;
}


sub _if($self) {
    if ( $self->_get_current_mem ) {
        $self->_nop;
    }
    else {
        my $nest_level = 0;
        my $max_iterations = $self->memory_size;

        SCAN:
        while (1) {
            $self->_incr_op_ptr;
            $max_iterations--;

            $nest_level++ and redo if $self->_current_op == $IF;

            if ( $self->_current_op == $EIF ) {
                if ( $nest_level ) {
                    $nest_level--;
                }
                else {
                    break SCAN;        
                }
            }

            croak "dud3, wh3r3's my EIF?" unless $max_iterations;
        }
    }

    return 1;
}

sub _eif($self) {
    if ( ! $self->_get_current_mem ) {
        $self->_nop;
    }



( run in 2.200 seconds using v1.01-cache-2.11-cpan-71847e10f99 )