Anonymous avatar Anonymous committed bcdbfbb

Use iter pirop instead of instantiating Iterator's. Parrot doesn't allow the latter anymore.

Comments (0)

Files changed (4)

Grammar/Actions.nqp

 
 method for_stmt($/) {
     # translates to:
-    # $P0 = new 'Iterator', <expression_list>
+    # $P0 = iter <expression_list>
     # while $P0:
     #   i = shift $P0
     #   ...
     my $list := $( $<expression_list> );
     my $iter := PAST::Var.new( :scope('register'), :node($/) );
     $past.push( PAST::Op.new( $iter, $list,
-                              :inline('    %0 = new "Iterator", %1'),
+                              :inline('    %0 = iter %1'),
                               :node($/) ) );
 
     # make loop body
     my $list := $( $<or_test> );
     my $iter := PAST::Var.new( :scope('register'), :node($/) );
     $past.push( PAST::Op.new( $iter, $list,
-                              :inline('    %0 = new "Iterator", %1'),
+                              :inline('    %0 = iter %1'),
                               :node($/) ) );
 
     # make loop body

src/builtins/funcs.pir

 
 .sub 'all'
     .param pmc iterable
-    .local pmc iter, result, obj
-    iter = new 'Iterator', iterable
+    .local pmc iterator, result, obj
+    iterator = iter iterable
     result = new 'Integer' # should be boolean or whatever
 
     .local int bool
   loop_check:
-    unless iter goto loop_end
-    obj = shift iter
+    unless iterator goto loop_end
+    obj = shift iterator
     bool = istrue obj
     unless bool goto fail
     goto loop_check
 
 .sub 'any'
     .param pmc iterable
-    .local pmc iter, result, obj
-    iter = new 'Iterator', iterable
+    .local pmc iterator, result, obj
+    iterator = iter iterable
     result = new 'Integer' # should be bool
     .local int bool
 
  loop_check:
-    unless iter goto fail
-    obj = shift iter
+    unless iterator goto fail
+    obj = shift iterator
     bool = istrue obj
     unless bool goto loop_check
 
     $I0 = 0
 make_iter_array_loop:
     $P0 = list_array[$I0]
-    $P1 = new 'Iterator', $P0
+    $P1 = iter $P0
     iter_array[$I0] = $P1
     inc $I0
     unless $I0 >= num_lists goto make_iter_array_loop
     .param pmc args :slurpy
 	#.param pmc key :named :optional        XXX
 
-	.local pmc iter, result
+	.local pmc iterator, result
 	
 	$I0 = elements args
 	if $I0 > 0 goto multiple_args
 	
-	iter = new 'Iterator', s
-	result = shift iter
+	iterator = iter s
+	result = shift iterator
 	goto loop_check
 
 multiple_args:
-	iter = new 'Iterator', args
+	iterator = iter args
 	result = s
 
 loop_check:
 	.local pmc i
-	unless iter goto loop_end
-	i = shift iter
+	unless iterator goto loop_end
+	i = shift iterator
 	unless i > result goto loop_check
 	set result, i
 	goto loop_check
     .param pmc args :slurpy
 	#.param pmc key :named :optional        XXX
 
-	.local pmc iter, result
+	.local pmc iterator, result
 
 	$I0 = elements args
 	if $I0 > 0 goto multiple_args
 
-	iter = new 'Iterator', s
-	result = shift iter
+	iterator = iter s
+	result = shift iterator
 	goto loop_check
 
 multiple_args:
-	iter = new 'Iterator', args
+	iterator = iter args
 	result = s
 
 loop_check:
 	.local pmc i
-	unless iter goto loop_end
-	i = shift iter
+	unless iterator goto loop_end
+	i = shift iterator
 	unless i < result goto loop_check
 	set result, i
 	goto loop_check
 	result = 0
 
 setup_loop:
-    .local pmc iter
-    iter = new 'Iterator', sequence
+    .local pmc iterator
+    iterator = iter sequence
 
     .local int i
 loop_check:
-    unless iter goto loop_end
-    i = shift iter
+    unless iterator goto loop_end
+    i = shift iterator
 	result += i
     goto loop_check
 

src/builtins/io.pir

     .param string end     :named('end') :optional
     .param int    got_end :opt_flag
 
-    .local pmc iter
+    .local pmc iterator
     .local string full_string, space
     full_string = ''
     space = ''
-    iter = new 'Iterator', args
+    iterator = iter args
   iter_loop:
-    unless iter goto iter_end
-    $S0 = shift iter
+    unless iterator goto iter_end
+    $S0 = shift iterator
     full_string .= space
     full_string .= $S0
     space = ' '

src/classes/pynielist.pir

 
 
 .sub 'get_string' :vtable
-    .local pmc iter
+    .local pmc iterator
     .local string result
 
-    iter = new 'Iterator', self
+    iterator = iter self
 
     result = '['
-    unless iter goto done
+    unless iterator goto done
 
     # first element separately, to handle commas properly
-    $P0 = shift iter
+    $P0 = shift iterator
     $S0 = 'repr'($P0)
     result .= $S0
 
 loop:
-    unless iter goto done
+    unless iterator goto done
     result .= ', '
 
-    $P0 = shift iter
+    $P0 = shift iterator
     $S0 = 'repr'($P0)
     result .= $S0
     goto loop
     if $I0 != $I1 goto no
 
     .local pmc i, j, item1, item2
-    i = new 'Iterator', self
-    j = new 'Iterator', other
+    i = iter self
+    j = iter other
 loop:
     # if no more elements and everything matched, then yes
     unless i goto yes
 .sub 'count' :method
     .param pmc value
 
-    .local pmc ret, iter
+    .local pmc ret, iterator
     ret = new 'Integer'
     ret = 0
     
-    iter = new 'Iterator', self
+    iterator = iter self
 loop:
-    unless iter goto done
-    $P0 = shift iter
+    unless iterator goto done
+    $P0 = shift iterator
     if $P0 != value goto loop
     inc ret
     goto loop
     if has_start goto not_yet
     if has_stop goto not_yet
 
-    .local pmc iter
+    .local pmc iterator
     .local int idx
     
     idx = -1
-    iter = new 'Iterator', self
+    iterator = iter self
 loop:
-    unless iter goto not_found
+    unless iterator goto not_found
     inc idx
-    $P0 = shift iter
+    $P0 = shift iterator
     unless $P0 == value goto loop
 
     # found!
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.