Permalink
Browse files

Change instances of "new 'Iterator', foo" to use "iter foo" instead

git-svn-id: http://svn.perl.org/parrot/trunk/languages/perl6@33742 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
perlpilot committed Dec 10, 2008
1 parent 38b5691 commit fcef7db4d92b0f7cb74917a9ceb83038bd30b682
View
@@ -147,14 +147,14 @@ the moment -- we'll do more complex handling a bit later.)
.sub 'die'
.param pmc list :slurpy
- .local pmc iter
+ .local pmc it
.local string message
message = ''
- iter = new 'Iterator', list
+ it = iter list
iter_loop:
- unless iter goto iter_end
- $P0 = shift iter
+ unless it goto iter_end
+ $P0 = shift it
$S0 = $P0
message .= $S0
goto iter_loop
View
@@ -315,12 +315,12 @@ need Undefs for non-existent elements (RSA gives empty strings).
.sub '!SETUP_ARGS'
.param pmc args_str
.param int strip_program_name
- .local pmc args, iter
+ .local pmc args, it
args = new 'List'
- iter = new 'Iterator', args_str
+ it = iter args_str
args_loop:
- unless iter goto args_end
- $P0 = shift iter
+ unless it goto args_end
+ $P0 = shift it
push args, $P0
goto args_loop
args_end:
@@ -341,7 +341,7 @@ Internal helper method to create a class.
.sub '!keyword_class'
.param string name :optional
.param int have_name :opt_flag
- .local pmc class, resolve_list, methods, iter
+ .local pmc class, resolve_list, methods, it
# Create class.
if have_name goto named
@@ -354,11 +354,11 @@ Internal helper method to create a class.
# Set resolve list to include all methods of the class.
methods = inspect class, 'methods'
- iter = new 'Iterator', methods
+ it = iter methods
resolve_list = new 'ResizableStringArray'
resolve_loop:
- unless iter goto resolve_loop_end
- $P0 = shift iter
+ unless it goto resolve_loop_end
+ $P0 = shift it
push resolve_list, $P0
goto resolve_loop
resolve_loop_end:
View
@@ -14,12 +14,12 @@ src/builtins/io.pir - Perl6 builtins for I/O
.sub 'print'
.param pmc args :slurpy
- .local pmc iter
+ .local pmc it
args.'!flatten'()
- iter = new 'Iterator', args
+ it = iter args
iter_loop:
- unless iter goto iter_end
- $S0 = shift iter
+ unless it goto iter_end
+ $S0 = shift it
print $S0
goto iter_loop
iter_end:
View
@@ -166,7 +166,7 @@ constant I<e>.
.param num exp :optional
.param int has_exp :opt_flag
.local num result, fracdivisor, magnitude
- .local pmc iter
+ .local pmc it
if radix <= 1 goto err_range
if radix > 36 goto err_range
@@ -175,11 +175,11 @@ constant I<e>.
fracdivisor = 1.0
$P0 = split '', intpart
- iter = new 'Iterator', $P0
+ it = iter $P0
lp1: # Accumulate over decimal part
- unless iter goto ex1
- $S0 = shift iter
+ unless it goto ex1
+ $S0 = shift it
$S0 = downcase $S0
if $S0 == "_" goto lp1
$I0 = index "0123456789abcdefghijklmnopqrstuvwxyz", $S0
@@ -197,8 +197,8 @@ constant I<e>.
$P99 = shift $P0 # remove the radix point
lp2: # Accumulate over fractional part, keep length
- unless iter goto ex2
- $S0 = shift iter
+ unless it goto ex2
+ $S0 = shift it
$S0 = downcase $S0
if $S0 == "_" goto lp2
$I0 = index "0123456789abcdefghijklmnopqrstuvwxyz", $S0
View
@@ -61,14 +61,14 @@ Writes the given list of items to the file.
.sub 'print' :method
.param pmc args :slurpy
- .local pmc iter
+ .local pmc it
.local pmc PIO
PIO = getattribute self, "$!PIO"
args = 'list'(args)
- iter = new 'Iterator', args
+ it = iter args
iter_loop:
- unless iter goto iter_end
- $S0 = shift iter
+ unless it goto iter_end
+ $S0 = shift it
print PIO, $S0
goto iter_loop
iter_end:
View
@@ -64,7 +64,7 @@ A List in list context returns itself.
.namespace ['List']
.sub 'Iterator' :method
self.'!flatten'()
- $P0 = new 'Iterator', self
+ $P0 = iter self
.return ($P0)
.end
View
@@ -52,12 +52,12 @@ ourself in a ObjectRef.
.sub 'get_string' :method :vtable
$S0 = ''
- .local pmc iter
- iter = new 'Iterator', self
+ .local pmc it
+ it = iter self
loop:
- unless iter goto end
- $S1 = shift iter
- $S2 = iter[$S1]
+ unless it goto end
+ $S1 = shift it
+ $S2 = it[$S1]
$S0 = concat $S0, $S1
concat $S0, "\t"
concat $S0, $S2
@@ -75,12 +75,12 @@ Return invocant as a Hash
=cut
.sub 'hash' :method
- .local pmc result, iter
+ .local pmc result, it
result = new 'Perl6Hash'
- iter = new 'Iterator', self
+ it = iter self
iter_loop:
- unless iter goto iter_end
- $S0 = shift iter
+ unless it goto iter_end
+ $S0 = shift it
$P0 = self[$S0]
result[$S0] = $P0
goto iter_loop
@@ -126,15 +126,15 @@ Returns elements of hash as array of C<Pair(key, value)>
=cut
.sub 'kv' :method :multi('Hash')
- .local pmc iter
+ .local pmc it
.local pmc rv
- iter = new 'Iterator', self
+ it = iter self
rv = new 'List'
loop:
- unless iter goto end
- $S1 = shift iter
+ unless it goto end
+ $S1 = shift it
push rv, $S1
- $P1 = iter[$S1]
+ $P1 = it[$S1]
push rv, $P1
goto loop
end:
@@ -148,15 +148,15 @@ Returns elements of hash as array of C<Pairs>
=cut
.sub 'pairs' :method :multi('Hash')
- .local pmc iter
+ .local pmc it
.local pmc rv
- iter = new 'Iterator', self
+ it = iter self
rv = 'list'()
$P3 = get_hll_global 'Perl6Pair'
loop:
- unless iter goto end
- $P1 = shift iter
- $P2 = iter[$P1]
+ unless it goto end
+ $P1 = shift it
+ $P2 = it[$P1]
$P4 = $P3.'new'('key' => $P1, 'value' => $P2)
push rv, $P4
goto loop
@@ -210,13 +210,13 @@ every pair, joined by newlines or an explicitly given separator.
.sub 'keys' :method :multi('Hash')
- .local pmc iter
+ .local pmc it
.local pmc rv
- iter = new 'Iterator', self
+ it = iter self
rv = new 'List'
loop:
- unless iter goto end
- $S1 = shift iter
+ unless it goto end
+ $S1 = shift it
push rv, $S1
goto loop
end:
@@ -228,12 +228,12 @@ every pair, joined by newlines or an explicitly given separator.
=cut
.sub 'reverse' :method :multi('Hash')
- .local pmc result, iter
+ .local pmc result, it
result = new 'Perl6Hash'
- iter = new 'Iterator', self
+ it = iter self
iter_loop:
- unless iter goto iter_end
- $S0 = shift iter
+ unless it goto iter_end
+ $S0 = shift it
$S1 = self[$S0]
result[$S1] = $S0
goto iter_loop
@@ -243,14 +243,14 @@ every pair, joined by newlines or an explicitly given separator.
.sub 'values' :method :multi('Hash')
- .local pmc iter
+ .local pmc it
.local pmc rv
- iter = new 'Iterator', self
+ it = iter self
rv = new 'List'
loop:
- unless iter goto end
- $S1 = shift iter
- $P1 = iter[$S1]
+ unless it goto end
+ $S1 = shift it
+ $P1 = it[$S1]
push rv, $P1
goto loop
end:
View
@@ -215,7 +215,7 @@ Create a new object having the same class as the invocant.
whence = self.'WHENCE'()
unless whence goto no_whence
.local pmc this_whence_iter
- this_whence_iter = new 'Iterator', whence
+ this_whence_iter = iter whence
this_whence_iter_loop:
unless this_whence_iter goto no_whence
$S0 = shift this_whence_iter
@@ -231,7 +231,7 @@ Create a new object having the same class as the invocant.
# the all_parents list includes ourself.
.local pmc all_parents, class_iter
all_parents = inspect $P0, "all_parents"
- class_iter = new 'Iterator', all_parents
+ class_iter = iter all_parents
class_iter_loop:
unless class_iter goto class_iter_loop_end
.local pmc cur_class
@@ -251,7 +251,7 @@ Create a new object having the same class as the invocant.
# Go through the provided init_parents to see if we have anything that
# matches.
.local pmc ip_iter, cur_ip
- ip_iter = new 'Iterator', init_parents
+ ip_iter = iter init_parents
ip_iter_loop:
unless ip_iter goto ip_iter_loop_end
cur_ip = shift ip_iter
@@ -282,12 +282,12 @@ Create a new object having the same class as the invocant.
found_init_attribs:
# Now go through attributes of the current class and iternate over them.
- .local pmc attribs, iter
+ .local pmc attribs, it
attribs = inspect cur_class, "attributes"
- iter = new 'Iterator', attribs
+ it = iter attribs
iter_loop:
- unless iter goto iter_end
- $S0 = shift iter
+ unless it goto iter_end
+ $S0 = shift it
# See if we have an init value; use Undef if not.
.local int got_init_value
@@ -113,7 +113,7 @@ Returns a proto-object with an autovivification closure attached to it.
from_list:
# List.
.local pmc list_iter, cur_pair
- list_iter = new 'Iterator', what
+ list_iter = iter what
list_iter_loop:
unless list_iter goto done_whence
cur_pair = shift list_iter
@@ -51,13 +51,13 @@
action = options['action']
## set up options based on flags
- .local pmc flagarray, iter
+ .local pmc flagarray, it
flagarray = split ' ', flags
- iter = new 'Iterator', flagarray
+ it = iter flagarray
iter_loop:
- unless iter goto iter_end
+ unless it goto iter_end
.local string oname
- oname = shift iter
+ oname = shift it
oname = substr oname, 1
options[oname] = 1
if oname == 'ww' goto opt_ww
@@ -154,11 +154,11 @@
## using an iterator to do it.
## wwdoubleopts = clone options
wwdoubleopts = new 'Hash'
- .local pmc iter2
- iter2 = new 'Iterator', options
+ .local pmc it2
+ it2 = iter options
iter2_loop:
- unless iter2 goto iter2_end
- $S0 = shift iter2
+ unless it2 goto iter2_end
+ $S0 = shift it2
$P0 = options[$S0]
wwdoubleopts[$S0] = $P0
goto iter2_loop
View
@@ -97,12 +97,12 @@ to the Perl 6 compiler.
## coming directly from Parrot, but currently Parrot provides
## it as a ResizableStringArray and we need Undefs for
## non-existent elements (RSA gives empty strings).
- .local pmc args, iter
+ .local pmc args, it
args = new 'ResizableStringArray'
- iter = new 'Iterator', args_str
+ it = iter args_str
args_loop:
- unless iter goto args_end
- $P0 = shift iter
+ unless it goto args_end
+ $P0 = shift it
push args, $P0
goto args_loop
args_end:

0 comments on commit fcef7db

Please sign in to comment.