Skip to content

Commit

Permalink
update some string opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
fperrad committed May 28, 2010
1 parent f6213ec commit 5855443
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/classes/String.pir
Expand Up @@ -198,7 +198,7 @@ Returns the characters in C<self> in reverse order. Destructive update.
.local pmc retv

tmps = self
downcase tmps
tmps = downcase tmps

retv = new 'CardinalString'
retv = tmps
Expand Down Expand Up @@ -237,7 +237,7 @@ Returns a copy of C<self> with all lower case letters converted to upper case
.local pmc retv

tmps = self
upcase tmps
tmps = upcase tmps

retv = new 'CardinalString'
retv = tmps
Expand All @@ -258,7 +258,7 @@ Returns a copy of C<self> with all lower case letters converted to upper case
if len == 0 goto done

substr fchr, tmps, 0, 1
downcase fchr
fchr = downcase fchr

concat retv, fchr
substr tmps, tmps, 1
Expand All @@ -281,7 +281,7 @@ Returns a copy of C<self> with all lower case letters converted to upper case
if len == 0 goto done

substr fchr, tmps, 0, 1
upcase fchr
fchr = upcase fchr

concat retv, fchr
substr tmps, tmps, 1
Expand Down Expand Up @@ -309,7 +309,7 @@ Returns a copy of C<self> with all lower case letters converted to upper case
len = length tmps
if len == 0 goto done

downcase tmps
tmps = downcase tmps

.local int pos, is_ws, is_lc
pos = 0
Expand All @@ -328,8 +328,8 @@ Returns a copy of C<self> with all lower case letters converted to upper case
#unless is_lc goto advance
unless is_lc goto done
$S1 = substr tmps, pos, 1
upcase $S1
substr tmps, pos, 1, $S1
$S1 = upcase $S1
tmps = replace tmps, pos, 1, $S1
## the length may have changed after replacement, so measure it again
len = length tmps
#goto advance
Expand Down Expand Up @@ -401,7 +401,7 @@ Returns a copy of C<self> with all lower case letters converted to upper case

retv = new 'CardinalString'
tmps = self
chopn tmps, 1
tmps = chopn tmps, 1
retv = tmps
.return(retv)
.end
Expand All @@ -411,7 +411,7 @@ Returns a copy of C<self> with all lower case letters converted to upper case
.local int len

tmps = self
chopn tmps, 1
tmps = chopn tmps, 1
self = tmps
.return(self)
.end
Expand Down Expand Up @@ -485,11 +485,11 @@ Warning: Partial implementation. Look for TODO
if start < 0 goto neg_access
goto oob
neg_access:
substr $S0, tmp, start, stop, replace_with
$S0 = replace tmp, start, stop, replace_with
self = tmp
.return()
pos_access:
substr $S0, tmp, start, stop, replace_with
$S0 = replace tmp, start, stop, replace_with
self = tmp
.return()
oob:
Expand Down

0 comments on commit 5855443

Please sign in to comment.