line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Language::Befunge. |
3
|
|
|
|
|
|
|
# Copyright (c) 2001-2009 Jerome Quelin, all rights reserved. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
6
|
|
|
|
|
|
|
# it under the same terms as Perl itself. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Language::Befunge::lib::FIXP; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5289
|
use 5.010; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
51
|
|
13
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
14
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
6
|
use constant PRECISION => 10000; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
17
|
1
|
|
|
1
|
|
903
|
use Math::Trig; |
|
1
|
|
|
|
|
18291
|
|
|
1
|
|
|
|
|
1372
|
|
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
0
|
1
|
|
sub new { return bless {}, shift; } |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub A { |
22
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
23
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my ($a, $b) = $ip->spop_mult(2); |
26
|
0
|
|
|
|
|
|
$ip->spush( $a & $b ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub B { |
30
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
31
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $a = $ip->spop / PRECISION; |
34
|
0
|
|
|
|
|
|
$ip->spush( int( rad2deg( acos_real($a) ) * PRECISION ) ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub C { |
38
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
39
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $a = deg2rad( $ip->spop / PRECISION ); |
42
|
0
|
|
|
|
|
|
$ip->spush( int( cos($a) * PRECISION ) ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub D { |
46
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
47
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $n = $ip->spop; |
50
|
0
|
|
|
|
|
|
$ip->spush( int( rand($n) ) ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub I { |
54
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
55
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $a = deg2rad( $ip->spop / PRECISION ); |
58
|
0
|
|
|
|
|
|
$ip->spush( int( sin($a) * PRECISION ) ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub J { |
62
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
63
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $a = $ip->spop / PRECISION; |
66
|
0
|
|
|
|
|
|
$ip->spush( int ( rad2deg( asin_real($a) ) * PRECISION ) ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub N { |
70
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
71
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $n = $ip->spop; |
74
|
0
|
|
|
|
|
|
$ip->spush( -$n ); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub O { |
78
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
79
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my ($a, $b) = $ip->spop_mult(2); |
82
|
0
|
|
|
|
|
|
$ip->spush( $a | $b ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub P { |
86
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
87
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my $n = $ip->spop; |
90
|
0
|
|
|
|
|
|
$ip->spush( int($n * pi) ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub Q { |
94
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
95
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
my $n = $ip->spop; |
98
|
0
|
|
|
|
|
|
$ip->spush( int( sqrt($n) ) ); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub R { |
102
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
103
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my ($a, $b) = $ip->spop_mult(2); |
106
|
0
|
|
|
|
|
|
$ip->spush( int( $a ** $b ) ); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub S { |
110
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
111
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $n = $ip->spop; |
114
|
0
|
0
|
|
|
|
|
$ip->spush(1) if $n > 0; |
115
|
0
|
0
|
|
|
|
|
$ip->spush(0) if $n == 0; |
116
|
0
|
0
|
|
|
|
|
$ip->spush(-1) if $n < 0; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub T { |
120
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
121
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
my $a = deg2rad( $ip->spop / PRECISION ); |
124
|
0
|
|
|
|
|
|
$ip->spush( int( tan($a) * PRECISION ) ); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub U { |
128
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
129
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
130
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
my $a = $ip->spop / PRECISION; |
132
|
0
|
|
|
|
|
|
$ip->spush( int ( rad2deg( atan($a) ) * PRECISION ) ); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub V { |
136
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
137
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
my $n = $ip->spop; |
140
|
0
|
|
|
|
|
|
$ip->spush( abs $n ); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub X { |
144
|
0
|
|
|
0
|
1
|
|
my ($self, $interp) = @_; |
145
|
0
|
|
|
|
|
|
my $ip = $interp->get_curip; |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
my ($a, $b) = $ip->spop_mult(2); |
148
|
0
|
|
|
|
|
|
$ip->spush( $a ^ $b ); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
__END__ |