Skip to content

Commit

Permalink
remove unused methods copied over from partcl
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Dec 13, 2009
1 parent 46f26de commit 3dbbb2b
Showing 1 changed file with 0 additions and 139 deletions.
139 changes: 0 additions & 139 deletions src/class/tcllist.pir
Expand Up @@ -39,34 +39,6 @@ A Tcl-style list
.HLL 'parrot'
.namespace [ 'TclList' ]

=head2 reverse

Reverse ourselves.

This algorithm is very generic and could easily be
moved back into parrot core where we'd be happy to inherit it.
=cut
.sub reverse :method
.local int low,high
low = 0
high = elements self
.local pmc swap1, swap2
loop:
if low >= high goto done
dec high
swap1 = self[low]
swap2 = self[high]
self[low] = swap2
self[high] = swap1
inc low
goto loop
done:
.return(self)
.end
=head2 get_string

Returns the list as a string
Expand Down Expand Up @@ -213,114 +185,3 @@ Returns the list as a string
retval_s = join " ", retval
.return(retval_s)
.end

=head2 assign_pmc

Copy the contents of other to self.

=cut

.sub assign_pmc :vtable
.param pmc other

$I0 = does other, 'array'
if $I0 goto array_style

$I0 = isa other, 'String'
if $I0 goto string_style

$I0 = isa other, 'Undef'
if $I0 goto undef_style

die "unable to assign to TclList"

array_style:
.local int size
.local pmc iterator, elem
iterator = iter other
self = 0
loop:
unless iterator goto done
elem = shift iterator
size = elements other
push self, elem
goto loop
done:
.return()

string_style:
.local pmc tclstring
tclstring = new 'TclString'
$S0 = other
tclstring = $S0
.return()

undef_style:
self = copy other
.return()
.end

=head getDictValue

=cut

.sub getDictValue :method

.local int sizeof_list
sizeof_list = elements self

$I0 = mod sizeof_list, 2
if $I0 == 1 goto odd_args

.local pmc result
result = new 'TclDict'

.local int pos
pos = 0

loop:
if pos >= sizeof_list goto done
$S1 = self[pos]
inc pos
$P2 = self[pos]
inc pos
$I0 = isa $P2, 'String'
if $I0 goto is_string
is_list:
$P2 = $P2.'getDictValue'()
result[$S1] = $P2
goto loop

is_string:
# Can we listify the value here? If so, make it into a dictionary.
$P3 = $P2.'getListValue'()
$I0 = elements $P3
if $I0 <= 1 goto only_string
push_eh only_string
$P3 = $P3.'getDictValue'()
pop_eh
result[$S1] = $P3
goto loop

only_string:
result[$S1] = $P2
goto loop

done:
.return (result)

odd_args:
die 'missing value to go with key'
.end

# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:

# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:

0 comments on commit 3dbbb2b

Please sign in to comment.