NAME
Inline::Parrot::parrot - a Parrot process
SYNOPSIS
use Inline::Parrot::parrot;
my $p = Inline::Parrot::parrot->new(
parrot_file_name => 'parrot',
parrot_interpreter_file_name => 'parrot-interp.pir',
parrot_options => [],
debug => 0,
);
my $output = $p->compile_and_run( <<'PARROT' );
.pcc_sub _x0
print "parrot ok\n"
invoke P1
end
.end
PARROT
print "output:\n" . $output . "\n";
DESCRIPTION
This module provides an object-oriented, low-level interface to a Parrot process.
The API is a bit unstable.
METHODS
* new
Creates an Inline::Parrot::parrot object.
Default parameters:
parrot_file_name => 'parrot',
parrot_interpreter_file_name => 'parrot-interp.pir',
parrot_options => [],
debug => 0,
The default parrot_file_name
is determined at installation time by Makefile.PL
.
* compile( $string )
my $status = $parrot->compile( $code );
Compiles the code, and leave the result in the Parrot process memory.
Returns a status string. The string format definition is not stable - see the source code for details.
* compile_and_run( $string )
my $status = $parrot->compile_and_run( $code );
Compiles the code, and leave the result in the Parrot process memory. The first subroutine in the code is called.
The string format definition is not stable - see the source code for details.
Perl parameters are passed as specified in the Parrot Calling Conventions: http://www.parrotcode.org/docs/pdd/pdd03_calling_conventions.html
The first subroutine in the code is called using the sequence:
find_global P0, "_subroutine_name"
invokecc
Subroutines should return using code like this:
invoke P1
or:
.local string s
s = "Goodbye"
.pcc_begin_return
.return s
.pcc_end_return
* open
Starts the Parrot process.
open
is called automatically by new
.
If a process is already open, the command is ignored.
If a process cannot be open, the program dies.
* close
Closes the Parrot process.
If there is no open process, the command is ignored.
* debug
Controls the emission of debugging messages.
debug(1)
starts, debug(0)
stops.
The contents of the messages is not stable.
* get_interpreter_code
Returns the location of the Parrot interpreter. This is a string like ~/lib/Inline/Parrot/parrot-interpreter.pir
.
This is a class method.
SEE ALSO
AUTHOR
Flavio S. Glock, <fglock@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2004 by Flavio S. Glock
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.