Skip to content

Commit

Permalink
track string opcode changes
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Jun 3, 2010
1 parent 3d716f9 commit 1b67909
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 45 deletions.
6 changes: 3 additions & 3 deletions runtime/builtin/file.pir
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ bad_args:

$S0 = substr filename, -1, 1
if $S0 != separator goto continue
chopn filename, 1
filename = chopn filename, 1

continue:
.local pmc array
Expand Down Expand Up @@ -408,7 +408,7 @@ bad_args:

# Trailing dirsep is removed.
if $S1 != "/" goto continue
chopn $S0, 1
$S0 = chopn $S0, 1

continue:
.local int pos, idx, last_idx
Expand All @@ -426,7 +426,7 @@ get_last_index:
done:
if last_idx == -1 goto whole
inc last_idx
substr $S0, 0, last_idx, ''
$S0 = replace $S0, 0, last_idx, ''

whole:
.return($S0)
Expand Down
4 changes: 2 additions & 2 deletions runtime/builtin/gets.pir
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
# simplistic newline chomp
lastchar = substr tmps,-1
if lastchar != "\n" goto done
chopn tmps, 1
tmps = chopn tmps, 1
lastchar = substr tmps,-1
if lastchar != "\r" goto done
chopn tmps, 1
tmps = chopn tmps, 1

done:
.return(tmps)
Expand Down
3 changes: 2 additions & 1 deletion runtime/builtin/info.pir
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ compile:
.iter(lexpad)
.While(iterator, {
elem = shift iterator
$S0 = substr elem, 0, 1, ''
$S0 = substr elem, 0, 1
elem = replace elem, 0, 1, ''
.If($S0=='$', {
push retval, elem
})
Expand Down
2 changes: 1 addition & 1 deletion runtime/builtin/read.pir
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
.Unless(nonewline, {
$S0 = substr contents, -1, 1
.If($S0=="\n", {
substr contents, -1, 1, ''
contents = replace contents, -1, 1, ''
})
})
}, {
Expand Down
2 changes: 1 addition & 1 deletion runtime/builtin/regsub.pir
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ handle_bs:

loop_done:

substr original_target, from, match_len, replStr
original_target = replace original_target, from, match_len, replStr

argc = elements argv
unless argc goto return_it
Expand Down
9 changes: 6 additions & 3 deletions runtime/builtin/scan.pir
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,15 @@ normal: # Now at beginning of class. Find the end marker..
$S0 = substr class_fmt, 0, 1
if $S0 != '-' goto handle_end
class['-'] = 1
$S0 = substr class_fmt, 0, 1, ''
$S0 = substr class_fmt, 0, 1
class_fmt = replace class_fmt, 0, 1, ''

handle_end:
$S0 = substr class_fmt, -1, 1
if $S0 != '-' goto loop_dash
class['-'] = 1
$S0 = substr class_fmt, -1, 1, ''
$S0 = substr class_fmt, -1, 1
class_fmt = replace class_fmt, -1, 1, ''

loop_dash:
$I0 = index class_fmt, '-'
Expand Down Expand Up @@ -261,7 +263,8 @@ range_loop:

range_loop_done:

$S0 = substr class_fmt, $I1, 3, ''
$S0 = substr class_fmt, $I1, 3
class_fmt = replace class_fmt, $I1, 3, ''
goto loop_dash

just_chars:
Expand Down
36 changes: 18 additions & 18 deletions runtime/builtin/string.pir
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@
chunk_len += 1

.str(portion, {substr orig_str, first_i, chunk_len})
downcase portion
substr orig_str, first_i, chunk_len, portion
portion = downcase portion
orig_str = replace orig_str, first_i, chunk_len, portion

.return(orig_str)
})
Expand Down Expand Up @@ -205,8 +205,8 @@
chunk_len += 1

.str(portion, {substr orig_str, first_i, chunk_len})
upcase portion
substr orig_str, first_i, chunk_len, portion
portion = upcase portion
orig_str = replace orig_str, first_i, chunk_len, portion

.return(orig_str)
})
Expand Down Expand Up @@ -247,8 +247,8 @@
chunk_len += 1

.str(portion, {substr orig_str, first_i, chunk_len})
titlecase portion
substr orig_str, first_i, chunk_len, portion
portion = titlecase portion
orig_str = replace orig_str, first_i, chunk_len, portion

.return(orig_str)
})
Expand Down Expand Up @@ -422,13 +422,13 @@
teststr = substr the_string, strpos, mapstrlen
# if nocase, tweak 'em both to lc.
if nocase == 0 goto test
downcase teststr
downcase mapstr
teststr = downcase teststr
mapstr = downcase mapstr
test:
if teststr != mapstr goto inner_next
$I0 = mappos + 1
replacementstr = map_list [ $I0 ]
substr the_string, strpos, mapstrlen,replacementstr
the_string = replace the_string, strpos, mapstrlen,replacementstr
skiplen = length replacementstr
goto outer_next

Expand Down Expand Up @@ -488,8 +488,8 @@
b = shift argv

unless nocase goto skip_lower
downcase a
downcase b
a = downcase a
b = downcase b
skip_lower:

if len == -1 goto skip_shorten
Expand Down Expand Up @@ -738,7 +738,7 @@
replace_do:
len = high - low
len += 1
substr the_string, low, len, $S4
the_string = replace the_string, low, len, $S4

replace_done:
.return(the_string)
Expand Down Expand Up @@ -770,7 +770,7 @@
$I1 = index $S2, char

if $I1 < 0 goto trimleft_done
substr $S1, 0, 1, ''
$S1 = replace $S1, 0, 1, ''
goto trimleft_do

trimleft_done:
Expand Down Expand Up @@ -801,7 +801,7 @@
$I1 = index $S2, char

if $I1 < 0 goto trimright_done
chopn $S1, 1
$S1 = chopn $S1, 1
goto trimright_do

trimright_done:
Expand Down Expand Up @@ -833,7 +833,7 @@
$I1 = index $S2, char

if $I1 < 0 goto trim_do2
chopn $S1, 1
$S1 = chopn $S1, 1
goto trim_do1

trim_do2:
Expand All @@ -844,7 +844,7 @@
$I1 = index $S2, char

if $I1 < 0 goto trim_done
substr $S1, 0, 1, ''
$S1 = replace $S1, 0, 1, ''
goto trim_do2

trim_done:
Expand Down Expand Up @@ -880,8 +880,8 @@
.return(0)

arg_nocase:
downcase $S1
downcase $S2
$S1 = downcase $S1
$S2 = downcase $S2
goto args_processment

arg_length:
Expand Down
2 changes: 1 addition & 1 deletion runtime/builtin/subst.pir
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ END_PIR
$I0 = match.'to'()
$I1 = $I0 - pos
substr str, pos, $I1, newstr
str = replace str, pos, $I1, newstr
pos = $I0
$I0 = length newstr
Expand Down
2 changes: 1 addition & 1 deletion runtime/conversions.pir
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ space:
not_space:
dec $I0
$I1 = $I2 - $I0
substr contents, $I0, $I1, ' '
contents = replace contents, $I0, $I1, ' '
dec $I1
len -= $I1
goto backslash_loop
Expand Down
5 changes: 3 additions & 2 deletions runtime/options.pir
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ init_loop:
if $I1 == -1 goto init_got_type
$I2 = $I1 + 1
type = substr switch, $I2, 1
substr switch, $I1, 2, '' # assume a single char following the :
switch = replace switch, $I1, 2, '' # assume a single char following the :

init_got_type:
with_type[switch] = type
Expand All @@ -172,7 +172,8 @@ init_loop_done:
loop:
if pos >= argv_len goto loop_done
arg = argv[pos]
$S1 = substr arg, 0, 1, ''
$S1 = substr arg, 0, 1
arg = replace arg, 0, 1, ''
# args must start with -
if $S1 != '-' goto loop_done
# and not have any whitespace.
Expand Down
2 changes: 1 addition & 1 deletion runtime/tcllib.pir
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ got_platform:
eq $S0, '$', trim
goto no_trim
trim:
substr titem, 0, 1, ''
titem = replace titem, 0, 1, ''
no_trim:
$P0 = sourcens[item]
symns[titem] = $P0
Expand Down
3 changes: 2 additions & 1 deletion runtime/variables.pir
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ was this a valid tcl-style level, or did we get this value as a default?
get_absolute:
# Is this an absolute?
$S0 = tcl_level
$S1 = substr $S0, 0, 1, ''
$S1 = substr $S0, 0, 1
$S0 = replace $S0, 0, 1, ''
if $S1 != '#' goto get_integer

push_eh default
Expand Down
18 changes: 9 additions & 9 deletions src/class/tclconst.pir
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ simple:
$I1 = exists backslashes[$I0]
if $I1 goto special
substr value, pos, 1, ''
value = replace value, pos, 1, ''
inc pos
goto loop
Expand Down Expand Up @@ -112,7 +112,7 @@ octal:
# > 7
octal_only1:
$S0 = chr octal_value
substr value, pos, 2, $S0
value = replace value, pos, 2, $S0
inc pos
goto loop
Expand All @@ -135,7 +135,7 @@ octal2:
octal_only2:
$S0 = chr octal_value
substr value, pos, 3, $S0
value = replace value, pos, 3, $S0
inc pos
goto loop
Expand All @@ -148,7 +148,7 @@ octal3:
octal_value += digit
$S0 = chr octal_value
substr value, pos, 4, $S0
value = replace value, pos, 4, $S0
inc pos
goto loop # can't have four digits, stop now.
Expand Down Expand Up @@ -184,15 +184,15 @@ hex_done:
$I0 = hex_pos - pos
if $I0 == 2 goto hex_not_really
$S0 = chr hex_value
substr value, pos, $I0, $S0
value = replace value, pos, $I0, $S0

inc pos

goto loop

hex_not_really:
# This was a \x escape that had no hex value..
substr value, pos, 2, 'x'
value = replace value, pos, 2, 'x'
inc pos
goto loop

Expand Down Expand Up @@ -238,20 +238,20 @@ uni_done:
uni_good:
$S0 = chr uni_value

substr value, pos, $I0, $S0
value = replace value, pos, $I0, $S0

inc pos
goto loop

uni_not_really:
# This was a \u escape that had no uni value..
substr value, pos, 2, 'u'
value = replace value, pos, 2, 'u'
inc pos
goto loop

special:
$S0 = backslashes[$I0]
substr value, pos, 2, $S0
value = replace value, pos, 2, $S0
inc pos
goto loop

Expand Down
2 changes: 1 addition & 1 deletion src/class/tclproc.pir
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ args_next:
goto args_loop

args_loop_done:
chopn args_info, 1
args_info = chopn args_info, 1

.If(is_slurpy, {
args_usage .= ' ...'
Expand Down

0 comments on commit 1b67909

Please sign in to comment.