Skip to content

Commit

Permalink
Move a few methods on List and Pair over to the Perl 6 setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Feb 18, 2009
1 parent a020241 commit 80fd5c5
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 351 deletions.
4 changes: 3 additions & 1 deletion build/Makefile.in
Expand Up @@ -106,7 +106,9 @@ BUILTINS_PIR = \
src/builtins/traits.pir \

SETTING = \
src/setting/Whatever.pm
src/setting/List.pm \
src/setting/Pair.pm \
src/setting/Whatever.pm \

PMCS = perl6str objectref perl6scalar mutablevar perl6multisub

Expand Down
29 changes: 0 additions & 29 deletions perl6_s1.pir

This file was deleted.

30 changes: 0 additions & 30 deletions src/classes/List.pir
Expand Up @@ -205,36 +205,6 @@ Return the number of elements in the list.
.return ($I0)
.end

=item perl()

Returns a Perl representation of a List.

=cut

.sub 'perl' :method
.local string result
result = '['

.local pmc iter
iter = self.'iterator'()
unless iter goto iter_done
iter_loop:
$P1 = shift iter
if null $P1 goto iter_null
$S1 = $P1.'perl'()
result .= $S1
goto iter_next
iter_null:
result .= 'undef'
iter_next:
unless iter goto iter_done
result .= ', '
goto iter_loop
iter_done:
result .= ']'
.return (result)
.end


.namespace ['List']
.sub 'reverse' :method
Expand Down
68 changes: 0 additions & 68 deletions src/classes/Pair.pir
Expand Up @@ -38,52 +38,6 @@ Delegates on to a method call '.:Xkey(Xval)'.
.tailcall topic.$S0($P0)
.end

=item key

Gets the key of the pair.

=cut

.sub 'key' :method
$P0 = getattribute self, '$!key'
.return ($P0)
.end

=item kv

Return key and value as a 2-element List.

=cut

.namespace ['Perl6Pair']
.sub 'kv' :method
$P0 = self.'key'()
$P1 = self.'value'()
.tailcall 'list'($P0, $P1)
.end


=item pairs

=cut

.sub 'pairs' :method
.tailcall self.'list'()
.end


=item value

Gets the value of the pair.

=cut

.sub 'value' :method
$P0 = getattribute self, '$!value'
.return ($P0)
.end



=item get_string() (vtable method)

Expand Down Expand Up @@ -123,28 +77,6 @@ the key and value.
.return(retv)
.end

=item perl

Returns a Perl code representation of the pair.

=cut

.sub perl :method
# Get key and value.
$P0 = self.'key'()
$P1 = self.'value'()

# Get perl representation
$S0 = $P0.'perl'()
$S1 = $P1.'perl'()

# build result
.local string result
result = concat $S0, ' => '
result .= $S1
.return (result)
.end


.namespace []

Expand Down
223 changes: 0 additions & 223 deletions src/cli.pir

This file was deleted.

12 changes: 12 additions & 0 deletions src/setting/List.pm
@@ -0,0 +1,12 @@
class List is also {

=begin item perl()
Returns a Perl representation of a List.
=end item
method perl() {
return '[' ~ self.map({ .perl }).join(", ") ~ ']';
}

}

0 comments on commit 80fd5c5

Please sign in to comment.