NAME
Language::Befunge::IP - an Instruction Pointer for a Befunge-97 program.
SYNOPSIS
DESCRIPTION
CONSTRUCTOR
new( )
Create a new Instruction Pointer.
clone( )
Clone the current Instruction Pointer with all its stacks, position, delta, etc. Change its unique ID.
ACCESSORS
set_pos( x, y )
Set the current position of the IP to the corresponding location.
All the following accessors are autoloaded.
id( id )
Get or set the unique ID of the IP.
curx( x )
Get or set the current x-coordinate of the IP.
cury( y )
Get or set the current y-coordinate of the IP.
dx( dx )
Get or set the horizontal offset of the IP.
dy( dy )
Get or set the vertical offset of the IP.
storx( x )
Get or set the x-coordinate of the storage offset of the IP.
story( y )
Get or set the y-coordinate of the storage offset of the IP.
input( [string] )
Get or set the input cache.
string_mode( [boolean] )
Get or set the string_mode of the IP.
space_pushed( [boolean] )
Get or set wether a space has been pushed on the stack when encountering a serie of spaces in string-mode.
ss( )
Get the stack of stack of the IP.
toss( )
Access the current stack (er, TOSS) of the IP.
soss( )
Get or set the SOSS.
PUBLIC METHODS
Internal stack
In this section, I speak about the stack. In fact, this is the TOSS - that is, the Top Of the Stack Stack.
In Befunge-98, standard stack operations occur transparently on the TOSS (as if there were only one stack, as in Befunge-93).
- scount( )
-
Return the number of elements in the stack.
- spush( value )
-
Push a value on top of the stack.
- spop( )
-
Pop a value from the stack. If the stack is empty, no error occurs and the method acts as if it popped a 0.
- spop_gnirts( )
-
Pop a 0gnirts string from the stack.
- sclear( )
-
Clear the stack.
- svalue( offset )
-
Return the
offset
th value of the TOSS, counting from top of the TOSS. The offset is interpreted as a negative value, that is, a call with an offset of2
or-2
would return the second value on top of the TOSS.
Stack stack
This section discusses about the stack stack. We can speak here about TOSS (Top Of Stack Stack) and SOSS (second on stack stack).
- ss_count( )
-
Return the number of stacks in the stack stack. This of course does not include the TOSS itself.
- ss_create( count )
-
Push the TOSS on the stack stack and create a new stack, aimed to be the new TOSS. Once created, transfer
count
elements from the SOSS (the former TOSS) to the TOSS. Transfer here means move - and not copy -, furthermore, order is preserved.If count is negative, then
count
zeroes are pushed on the new TOSS. - ss_remove( count )
-
Move
count
elements from TOSS to SOSS, discard TOSS and make the SOSS become the new TOSS. Order of elems is preserved. - ss_transfer( count )
-
Transfer
count
elements from SOSS to TOSS, or from TOSS to SOSS ifcount
is negative; the transfer is done via pop/push.The order is not preserved, it is reversed.
- ss_sizes( )
-
Return a list with all the sizes of the stacks in the stack stack (including the TOSS), from the TOSS to the BOSS.
- soss_count( )
-
Return the number of elements in SOSS.
- soss_push( value )
-
Push a value on top of the SOSS.
- soss_pop( )
-
Pop a value from the SOSS. If the stack is empty, no error occurs and the method acts as if it popped a 0.
- soss_clear( )
-
Clear the SOSS.
Changing direction
- set_delta( dx, dy )
-
Implements the
x
instruction. Set the delta vector of the IP according to the provided values. - dir_go_east( )
-
Implements the
>
instruction. Force the IP to travel east. - dir_go_west( )
-
Implements the
<
instruction. Force the IP to travel west. - dir_go_north( )
-
Implements the
^
instruction. Force the IP to travel north. - dir_go_south( )
-
Implements the
v
instruction. Force the IP to travel south. - dir_go_away( )
-
Implements the
?
instruction. Cause the IP to travel in a random cardinal direction ( north, south, east or west). - dir_turn_left( )
-
Implements the
[
instruction. Rotate by 90 degrees on the left the delta of the IP which encounters this instruction. - dir_turn_right( )
-
Implements the
]
instruction. Rotate by 90 degrees on the right the delta of the IP which encounters this instruction. - dir_reverse( )
-
Implements the
r
instruction. Reverse the direction of the IP, that is, multiply the IP's delta by -1.
PRIVATE METHODS
get_new_id( )
Forge a new IP id, that will distinct it from the other IPs of the program.
AUTHOR
Jerome Quelin, <jquelin@cpan.org>
COPYRIGHT
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 597:
You forgot a '=back' before '=head1'
- Around line 613:
=back without =over