2 # This file is part of Language::Befunge.
3 # Copyright (c) 2001-2009 Jerome Quelin, all rights reserved.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the same terms as Perl itself.
10 package Language
::Befunge
::lib
::REFC
;
15 use Language
::Befunge
::Vector
;
17 sub new
{ return bless {}, shift; }
25 # 'Reference' pops a vector off the stack, and pushes a scalar value back onto
26 # the stack, unique within an internal list of references, which refers to that
30 my ($self, $lbi) = @_;
31 my $ip = $lbi->get_curip;
32 my $v = $ip->spop_vec;
34 $ip->spush( $#vectors );
41 # 'Dereference' pops a scalar value off the stack, and pushes the vector back
42 # onto the stack which corresponds to that unique reference value.
45 my ($self, $lbi) = @_;
46 my $ip = $lbi->get_curip;
48 my $v = $vectors[$id];
49 $ip->spush( $v->get_component(0), $v->get_component(1) );
60 Language::Befunge::IP::lib::REFC - Referenced cells extension
67 The REFC fingerprint (0x52454643) allows vectors to be encoded into and
68 decoded from single scalar cell values.
70 Note that the internal list of references is considered shared among all
79 Create a new REFC instance.
86 =item $id = R( $x, $y )
88 C<Reference> pops a vector off the stack, and pushes a scalar value back onto
89 the stack, unique within an internal list of references, which refers to that
93 =item ($x, $y) = D( $id )
95 C<Dereference> pops a scalar value off the stack, and pushes the vector back
96 onto the stack which corresponds to that unique reference value.
105 L<Language::Befunge>, L<http://catseye.tc/projects/funge98/library/REFC.html>.
111 Jerome Quelin, C<< <jquelin@cpan.org> >>
114 =head1 COPYRIGHT & LICENSE
116 Copyright (c) 2001-2009 Jerome Quelin, all rights reserved.
118 This program is free software; you can redistribute it and/or modify
119 it under the same terms as Perl itself.