| 1 | package Acme::Aheui; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Term::ReadKey; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Encode qw/encode/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | Acme::Aheui - an aheui interpreter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | Version 0.04 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | our $VERSION = '0.04'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | use Acme::Aheui; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | my $interpreter = Acme::Aheui->new( source => '아희' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | $interpreter->execute(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | An aheui interpreter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | See aheui language specification at L<https://aheui.github.io/specification.en> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | Most logic is based on the reference implementation by Puzzlet Chung. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | (L<https://github.com/aheui/jsaheui>) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | JONG_STROKE_NUMS => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | [0, 2, 4, 4, 2, 5, 5, 3, 5, 7, 9, 9, 7, 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 9, 8, 4, 4, 6, 2, 4, 1, 3, 4, 3, 4, 4, 3], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | REQUIRED_ELEM_NUMS => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | [0, 0, 2, 2, 2, 2, 1, 0, 1, 0, 1, 0, 2, 0, 1, 0, 2, 2, 0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | =head1 PUBLIC METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | my $interpreter = Acme::Aheui->new( source => '아희' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | This method will create and return C<Acme::Aheui> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 9 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 9 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 9 | ▶ | my $source = $args{source} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{'source'} || ''
MC/DC100%1/1
$args{'source'} || ''
$args{'source'}
Truth table100%2/2
A
A= $args{'source'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 9 | my $codespace = build_codespace($source); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 9 | my $self = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | _codespace => $codespace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | _stacks => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | _stack_index => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | _x => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | _y => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | _dx => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | _dy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 9 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | sub build_codespace { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 9 | ▶ | my ($source) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_codespace: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 9 | my @lines = split /\r?\n/, $source; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 9 | my @rows = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 9 | for my $line (@lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 25 | my @row = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 25 | for my $char (split //, $line) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 112 | my $disassembled = disassemble_hangul_char($char); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 112 | push @row, $disassembled; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 25 | push @rows, \@row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 9 | return \@rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | sub disassemble_hangul_char { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 112 | ▶ | my ($char) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disassemble_hangul_char: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 112 | ▶ | if ($char =~ /[가-힣]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 99 | my $code = unpack 'U', $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 99 | $code -= 0xAC00; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 99 | my ($cho, $jung, $jong) = (int($code/28/21), ($code/28)%21, $code%28); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 99 | return {cho => $cho, jung => $jung, jong => $jong}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 13 | return {cho => -1, jung => -1, jong => -1}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | =head2 execute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | $interpreter->execute(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | This method will execute the aheui program and return the exit code. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | It may use C<STDIN> and/or C<STDOUT> if the aheui program uses I/O. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 6 | ▶ | return 0 unless $self->_has_initial_command(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 4 | return $self->_loop_steps(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | sub _has_initial_command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_has_initial_command: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 6 | for my $row (@{ $self->{_codespace} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 10 | my $first_command = @$row[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 10 | ▶ | if ($first_command && $$first_command{cho} != -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$first_command and $first_command->{"cho"} != -1
MC/DC100%2/2
$first_command and $first_command->{"cho"} != -1
$first_command
$first_command->{"cho"} != -1
Truth table100%3/3
A and B
A= $first_commandB= $first_command->{"cho"} != -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | sub _loop_steps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_loop_steps: called CC=27 SCAR=39.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 4 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 76 | my $codespace = $self->{_codespace}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 76 | my ($x, $y) = ($self->{_x}, $self->{_y}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 76 | ▶ | if ($x > $#{$$codespace[$y]}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $self->_move_cursor(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 76 | my $c = $$codespace[$y][$x]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 76 | ▶ | if (!$c || $c->{cho} == -1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $c or $c->{"cho"} == -1
MC/DC0%0/2
not $c or $c->{"cho"} == -1
not $c
$c->{"cho"} == -1
Truth table33%1/3
not(A) or B
A= not $cB= $c->{"cho"} == -1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $self->_move_cursor(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 76 | my $cho = $c->{cho}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 76 | my $jung = $c->{jung}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 76 | my $jong = $c->{jong}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 76 | my $si = $self->{_stack_index}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 76 | my ($dx, $dy) = $self->_get_deltas_upon_jung($jung); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 76 | $self->{_dx} = $dx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 76 | $self->{_dy} = $dy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 76 | my $stack = $self->{_stacks}->[$si]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 76 | ▶ | my $elem_num = ($stack) ? scalar @{$stack} : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 76 | ▶ | if ($elem_num < REQUIRED_ELEM_NUMS->[$cho]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $self->{_dx} = -($self->{_dx}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $self->{_dy} = -($self->{_dy}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 76 | ▶ | if ($cho == 2) { # ㄴ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 14 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $m = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $n = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $self->_push($si, int($n/$m)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | elsif ($cho == 3) { # ㄷ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 8 | my $m = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 8 | my $n = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 8 | $self->_push($si, $n+$m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | elsif ($cho == 16) { # ㅌ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 3 | my $m = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 3 | my $n = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 3 | $self->_push($si, $n-$m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | elsif ($cho == 4) { # ㄸ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 6 | my $m = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 6 | my $n = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 6 | $self->_push($si, $n*$m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | elsif ($cho == 5) { # ㄹ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $m = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my $n = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $self->_push($si, $n%$m); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | elsif ($cho == 6) { # ㅁ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 18 | my $v = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 18 | ▶ | if ($jong == 21) { # jongㅇ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | $self->_output_number($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | elsif ($jong == 27) { # jongㅎ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 16 | $self->_output_code_as_character($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | elsif ($cho == 7) { # ㅂ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 24 | my $v = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 24 | ▶ | if ($jong == 21) { # jongㅇ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | $v = $self->_get_input_number(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | elsif ($jong == 27) { # jongㅎ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | $v = $self->_get_input_character_as_code(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | else { # the other jongs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 21 | $v = JONG_STROKE_NUMS->[$jong]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 24 | $self->_push($si, $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | elsif ($cho == 8) { # ㅃ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 12 | $self->_duplicate($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | elsif ($cho == 17) { # ㅍ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | $self->_swap($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | elsif ($cho == 9) { # ㅅ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $self->{_stack_index} = $jong; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | elsif ($cho == 10) { # ㅆ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $self->_push($jong, $self->_pop($si)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | elsif ($cho == 12) { # ㅈ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my $m = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $n = $self->_pop($si); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | my $in = ($n >= $m) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $self->_push($si, $in); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | elsif ($cho == 14) { # ㅊ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | if ($self->_pop($si) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $self->{_dx} = -($self->{_dx}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $self->{_dy} = -($self->{_dy}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | elsif ($cho == 18) { # ㅎ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 4 | ▶ | my $ret = $self->_pop($si) || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->_pop($si) || 0
MC/DC100%1/1
$self->_pop($si) || 0
$self->_pop($si)
Truth table100%2/2
A
A= $self->_pop($si)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 4 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 72 | $self->_move_cursor(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | sub _move_cursor { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 101 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_move_cursor: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 101 | my $codespace = $self->{_codespace}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 101 | $self->{_x} += $self->{_dx}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 101 | $self->{_y} += $self->{_dy}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 101 | my $last_row_index = $#{ $codespace }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 101 | ▶ | if ($self->{_y} < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | $self->{_y} = $last_row_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 101 | ▶ | if ($self->{_y} > $last_row_index) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | $self->{_y} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 101 | my $last_char_index = $#{ @$codespace[$self->{_y}] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 101 | ▶ | if ($self->{_x} < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 4 | $self->{_x} = $last_char_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 101 | ▶ | if ($self->{_x} > $last_char_index && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"_x"} > $last_char_index and $self->{"_dx"} != 0
MC/DC100%2/2
$self->{"_x"} > $last_char_index and $self->{"_dx"} != 0
$self->{"_x"} > $last_char_index
$self->{"_dx"} != 0
Truth table100%3/3
A and B
A= $self->{"_x"} > $last_char_indexB= $self->{"_dx"} != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | $self->{_dx} != 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 3 | $self->{_x} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | sub _get_deltas_upon_jung { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 76 | ▶ | my ($self, $jung) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_deltas_upon_jung: called CC=12 SCAR=28.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 76 | my $dx = $self->{_dx}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 76 | my $dy = $self->{_dy}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 76 | ▶ | if ($jung == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 11 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 28 | return (1, 0); # ㅏ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | elsif ($jung == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | return (2, 0); # ㅑ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | elsif ($jung == 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 16 | return (-1, 0); # ㅓ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | elsif ($jung == 6) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | return (-2, 0); # ㅕ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | elsif ($jung == 8) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 12 | return (0, -1); # ㅗ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | elsif ($jung == 12) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | return (0, -2); # ㅛ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | elsif ($jung == 13) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 16 | return (0, 1); # ㅜ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | elsif ($jung == 17) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | return (0, 2); # ㅠ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | elsif ($jung == 18) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | return ($dx, -$dy); # ㅡ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | elsif ($jung == 19) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | return (-$dx, -$dy); # ㅢ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | elsif ($jung == 20) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 3 | return (-$dx, $dy); # ㅣ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | return ($dx, $dy); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | sub _push { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 257 | ▶ | my ($self, $i, $n) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_push: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 257 | ▶ | if ($i == 27) { # ㅎ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 257 | push @{$self->{_stacks}->[$i]}, $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | sub _pop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 299 | ▶ | my ($self, $i) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pop: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 299 | my $stack = $self->{_stacks}->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 299 | ▶ | if ($i == 21) { # ㅇ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 9 | return shift @$stack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | elsif ($i == 27) { # ㅎ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 290 | return pop @$stack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | sub _duplicate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 39 | ▶ | my ($self, $i) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_duplicate: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 39 | my $stack = $self->{_stacks}->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 39 | ▶ | if ($i == 21) { # ㅇ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | my $first = $$stack[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 1 | unshift @$stack, $first; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | elsif ($i == 27) { # ㅎ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 38 | my $last = $$stack[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 38 | push @$stack, $last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | sub _swap { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 28 | ▶ | my ($self, $i) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_swap: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 28 | my $stack = $self->{_stacks}->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 28 | ▶ | if ($i == 21) { # ㅇ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | my $first = $$stack[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 1 | my $second = $$stack[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | $$stack[0] = $second; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | $$stack[1] = $first; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | elsif ($i == 27) { # ㅎ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 27 | my $last = $$stack[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 27 | my $next = $$stack[-2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 27 | $$stack[-1] = $next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 27 | $$stack[-2] = $last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | sub _output_number { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 2 | ▶ | my ($self, $number) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_output_number: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 2 | print $number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | sub _output_code_as_character { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 16 | ▶ | my ($self, $code) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_output_code_as_character: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 16 | my $unichar = pack 'U', $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 16 | print encode('utf-8', $unichar); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | sub _get_input_character_as_code { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_input_character_as_code: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 2 | my $char = ReadKey(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 2 | return unpack 'U', $char; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | sub _get_input_number { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_input_number: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | return int(ReadLine(0)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | =head1 INSTALLATION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | To install this module, run the following commands: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | perl Build.PL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | ./Build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | ./Build test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ./Build install | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | Rakjin Hwang, C<< <rakjin@cpan.org> >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||