[svn:parrot] r40200 - in trunk/examples: json languages/squaak/src/builtins past pir sdl/minesweeper shootout tutorial

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Jul 21 21:51:54 UTC 2009


Author: bacek
Date: Tue Jul 21 21:51:54 2009
New Revision: 40200
URL: https://trac.parrot.org/parrot/changeset/40200

Log:
[cage] Use iter opcode instead of new Iterator in examples

Modified:
   trunk/examples/json/postalcodes.pir
   trunk/examples/languages/squaak/src/builtins/say.pir
   trunk/examples/past/01-sub.pir
   trunk/examples/past/four_plus_one.pir
   trunk/examples/pir/pirric.pir
   trunk/examples/pir/quine_ord.pir
   trunk/examples/pir/sudoku.pir
   trunk/examples/sdl/minesweeper/field.pir
   trunk/examples/shootout/knucleotide.pir
   trunk/examples/shootout/regexdna.pir
   trunk/examples/tutorial/55_iterator.pir

Modified: trunk/examples/json/postalcodes.pir
==============================================================================
--- trunk/examples/json/postalcodes.pir	Tue Jul 21 21:51:08 2009	(r40199)
+++ trunk/examples/json/postalcodes.pir	Tue Jul 21 21:51:54 2009	(r40200)
@@ -78,12 +78,12 @@
     unless null $P3 goto bad_code
 
     $P2 = $P2['postalCodes']
-    .local pmc iter, code
-    iter = new 'Iterator', $P2
+    .local pmc it, code
+    it = iter $P2
 
  code_loop:
     push_eh code_end
-      code = shift iter
+      code = shift it
     pop_eh
     unless code goto code_end
 

Modified: trunk/examples/languages/squaak/src/builtins/say.pir
==============================================================================
--- trunk/examples/languages/squaak/src/builtins/say.pir	Tue Jul 21 21:51:08 2009	(r40199)
+++ trunk/examples/languages/squaak/src/builtins/say.pir	Tue Jul 21 21:51:54 2009	(r40200)
@@ -12,11 +12,11 @@
 
 .sub 'print'
     .param pmc args            :slurpy
-    .local pmc iter
-    iter = new 'Iterator', args
+    .local pmc it
+    it = iter args
   iter_loop:
-    unless iter goto iter_end
-    $P0 = shift iter
+    unless it goto iter_end
+    $P0 = shift it
     print $P0
     goto iter_loop
   iter_end:

Modified: trunk/examples/past/01-sub.pir
==============================================================================
--- trunk/examples/past/01-sub.pir	Tue Jul 21 21:51:08 2009	(r40199)
+++ trunk/examples/past/01-sub.pir	Tue Jul 21 21:51:54 2009	(r40200)
@@ -100,11 +100,11 @@
 .sub 'say'
     .param pmc args :slurpy
     if null args goto end
-    .local pmc iter
-    iter = new 'Iterator', args
+    .local pmc it
+    it = iter args
   loop:
-    unless iter goto end
-    $P0 = shift iter
+    unless it goto end
+    $P0 = shift it
     print $P0
     goto loop
   end:

Modified: trunk/examples/past/four_plus_one.pir
==============================================================================
--- trunk/examples/past/four_plus_one.pir	Tue Jul 21 21:51:08 2009	(r40199)
+++ trunk/examples/past/four_plus_one.pir	Tue Jul 21 21:51:54 2009	(r40200)
@@ -116,11 +116,11 @@
 .sub 'say'
     .param pmc args :slurpy
     if null args goto end
-    .local pmc iter
-    iter = new 'Iterator', args
+    .local pmc it
+    it = iter args
   loop:
-    unless iter goto end
-    $P0 = shift iter
+    unless it goto end
+    $P0 = shift it
     print $P0
     goto loop
   end:

Modified: trunk/examples/pir/pirric.pir
==============================================================================
--- trunk/examples/pir/pirric.pir	Tue Jul 21 21:51:08 2009	(r40199)
+++ trunk/examples/pir/pirric.pir	Tue Jul 21 21:51:54 2009	(r40200)
@@ -2452,7 +2452,7 @@
 .sub begin :method
     .local pmc text
     text = getattribute self, 'lines'
-    new $P0, 'Iterator', text
+    iter $P0, text
     set $P0, .ITERATE_FROM_START
     .return($P0)
 .end

Modified: trunk/examples/pir/quine_ord.pir
==============================================================================
--- trunk/examples/pir/quine_ord.pir	Tue Jul 21 21:51:08 2009	(r40199)
+++ trunk/examples/pir/quine_ord.pir	Tue Jul 21 21:51:54 2009	(r40200)
@@ -2171,8 +2171,6 @@
 push code_as_data, 32
 push code_as_data, 105
 push code_as_data, 116
-push code_as_data, 101
-push code_as_data, 114
 push code_as_data, 10
 push code_as_data, 32
 push code_as_data, 32
@@ -2203,26 +2201,13 @@
 push code_as_data, 32
 push code_as_data, 105
 push code_as_data, 116
-push code_as_data, 101
-push code_as_data, 114
 push code_as_data, 32
 push code_as_data, 61
 push code_as_data, 32
-push code_as_data, 110
-push code_as_data, 101
-push code_as_data, 119
-push code_as_data, 32
-push code_as_data, 39
-push code_as_data, 73
+push code_as_data, 105
 push code_as_data, 116
 push code_as_data, 101
 push code_as_data, 114
-push code_as_data, 97
-push code_as_data, 116
-push code_as_data, 111
-push code_as_data, 114
-push code_as_data, 39
-push code_as_data, 44
 push code_as_data, 32
 push code_as_data, 100
 push code_as_data, 97
@@ -2235,8 +2220,6 @@
 push code_as_data, 32
 push code_as_data, 105
 push code_as_data, 116
-push code_as_data, 101
-push code_as_data, 114
 push code_as_data, 32
 push code_as_data, 61
 push code_as_data, 32
@@ -2321,8 +2304,6 @@
 push code_as_data, 32
 push code_as_data, 105
 push code_as_data, 116
-push code_as_data, 101
-push code_as_data, 114
 push code_as_data, 32
 push code_as_data, 103
 push code_as_data, 111
@@ -2395,8 +2376,6 @@
 push code_as_data, 32
 push code_as_data, 105
 push code_as_data, 116
-push code_as_data, 101
-push code_as_data, 114
 push code_as_data, 32
 push code_as_data, 32
 push code_as_data, 32
@@ -2630,8 +2609,6 @@
 push code_as_data, 32
 push code_as_data, 105
 push code_as_data, 116
-push code_as_data, 101
-push code_as_data, 114
 push code_as_data, 10
 push code_as_data, 32
 push code_as_data, 32
@@ -2639,26 +2616,13 @@
 push code_as_data, 32
 push code_as_data, 105
 push code_as_data, 116
-push code_as_data, 101
-push code_as_data, 114
 push code_as_data, 32
 push code_as_data, 61
 push code_as_data, 32
-push code_as_data, 110
-push code_as_data, 101
-push code_as_data, 119
-push code_as_data, 32
-push code_as_data, 39
-push code_as_data, 73
+push code_as_data, 105
 push code_as_data, 116
 push code_as_data, 101
 push code_as_data, 114
-push code_as_data, 97
-push code_as_data, 116
-push code_as_data, 111
-push code_as_data, 114
-push code_as_data, 39
-push code_as_data, 44
 push code_as_data, 32
 push code_as_data, 100
 push code_as_data, 97
@@ -2671,8 +2635,6 @@
 push code_as_data, 32
 push code_as_data, 105
 push code_as_data, 116
-push code_as_data, 101
-push code_as_data, 114
 push code_as_data, 32
 push code_as_data, 61
 push code_as_data, 32
@@ -2814,8 +2776,6 @@
 push code_as_data, 32
 push code_as_data, 105
 push code_as_data, 116
-push code_as_data, 101
-push code_as_data, 114
 push code_as_data, 32
 push code_as_data, 103
 push code_as_data, 111
@@ -2888,8 +2848,6 @@
 push code_as_data, 32
 push code_as_data, 105
 push code_as_data, 116
-push code_as_data, 101
-push code_as_data, 114
 push code_as_data, 32
 push code_as_data, 32
 push code_as_data, 32
@@ -3622,14 +3580,14 @@
     .param pmc data
 
    .include "iterator.pasm"
-   .local pmc iter
+   .local pmc it
    .local int char_int
 
-   iter = new 'Iterator', data
-    iter = .ITERATE_FROM_START # reset iterator, begin at start
+   it = iter data
+    it = .ITERATE_FROM_START # reset iterator, begin at start
     ITER_LOOP:
-    unless iter goto ITER_END         # while (entries) ...
-        char_int = shift iter         # get entry
+    unless it goto ITER_END         # while (entries) ...
+        char_int = shift it         # get entry
         print 'push code_as_data, '
         print char_int
         print "\n"
@@ -3643,16 +3601,16 @@
 
    .include "iterator.pasm"
 
-   .local pmc iter
-    iter = new 'Iterator', data
-    iter = .ITERATE_FROM_START # reset iterator, begin at start
+   .local pmc it
+    it = iter data
+    it = .ITERATE_FROM_START # reset iterator, begin at start
 
    .local int    char_int
    .local string char_string
 
     ITER_LOOP:
-    unless iter goto ITER_END         # while (entries) ...
-        char_int = shift iter         # get entry
+    unless it goto ITER_END         # while (entries) ...
+        char_int = shift it         # get entry
         char_string = chr char_int
         print char_string
         goto ITER_LOOP

Modified: trunk/examples/pir/sudoku.pir
==============================================================================
--- trunk/examples/pir/sudoku.pir	Tue Jul 21 21:51:08 2009	(r40199)
+++ trunk/examples/pir/sudoku.pir	Tue Jul 21 21:51:54 2009	(r40200)
@@ -339,7 +339,7 @@
     if name goto sel_name
 
 list_names:
-    new it, 'Iterator', b
+    it = iter b
     it = .ITERATE_FROM_START
 loop:
     unless it goto fin
@@ -901,7 +901,7 @@
 .sub check_seen
     .param pmc seen
     .local pmc it
-    new it, 'Iterator', seen
+    it = iter seen
     it = .ITERATE_FROM_START
 loop:
     unless it goto ok

Modified: trunk/examples/sdl/minesweeper/field.pir
==============================================================================
--- trunk/examples/sdl/minesweeper/field.pir	Tue Jul 21 21:51:08 2009	(r40199)
+++ trunk/examples/sdl/minesweeper/field.pir	Tue Jul 21 21:51:54 2009	(r40200)
@@ -290,11 +290,11 @@
     .local pmc status
 
     getattribute field, self, 'field'
-    field   = new "Iterator", field
+    field   = iter field
     field   = .ITERATE_FROM_START
 
     cache   = getattribute self, 'cache'
-    cacheit = new "Iterator", cache
+    cacheit = iter cache
     cacheit = .ITERATE_FROM_START
 
     screen  = getattribute self, 'screen'
@@ -839,7 +839,7 @@
     .local pmc field
 
     field = getattribute self, 'field'
-    field = new 'Iterator', field
+    field = iter field
     field = .ITERATE_FROM_START
 LOOP:
     unless field goto WON
@@ -910,7 +910,7 @@
     mines_lcd = getattribute self, 'mines_lcd'
 
     size  = field
-    field = new 'Iterator', field
+    field = iter field
     field = .ITERATE_FROM_START
     count = new 'ResizablePMCArray'
 

Modified: trunk/examples/shootout/knucleotide.pir
==============================================================================
--- trunk/examples/shootout/knucleotide.pir	Tue Jul 21 21:51:08 2009	(r40199)
+++ trunk/examples/shootout/knucleotide.pir	Tue Jul 21 21:51:54 2009	(r40200)
@@ -65,13 +65,13 @@
 	$I0 = elements table
 	array = $I0
 
-	.local pmc iter
-   	iter = new 'Iterator', table
-	set iter, .ITERATE_FROM_START
+	.local pmc it
+    it = iter table
+	set it, .ITERATE_FROM_START
 	i = 0
 iter_loop_1:
-	unless iter goto iter_end_1
-	$S0 = shift iter
+	unless it goto iter_end_1
+	$S0 = shift it
 	$I0 = table[$S0]
 	$P0 = new 'FixedPMCArray'
 	$P0 = 2

Modified: trunk/examples/shootout/regexdna.pir
==============================================================================
--- trunk/examples/shootout/regexdna.pir	Tue Jul 21 21:51:08 2009	(r40199)
+++ trunk/examples/shootout/regexdna.pir	Tue Jul 21 21:51:54 2009	(r40200)
@@ -3,7 +3,7 @@
 
 .sub main :main
 	load_bytecode "PGE.pbc"
-	.local pmc p6rule_compile, rulesub, match, variants, variants_p5, iub, iter, matches, capt
+	.local pmc p6rule_compile, rulesub, match, variants, variants_p5, iub, it, matches, capt
 	.local string pattern, chunk, seq, key, replacement
 	.local int readlen, chunklen, seqlen, finallen, i, varnum, count
 	p6rule_compile = compreg "PGE::Perl6Regex"
@@ -121,12 +121,12 @@
 	#####################################################
 	# Final replace to make the sequence a p5 style regex
 	.include "iterator.pasm"
-	iter = new 'Iterator', iub
-	set iter, .ITERATE_FROM_START
+	it = iter iub
+	set it, .ITERATE_FROM_START
 	matches = new 'ResizablePMCArray'
 iter_loop:
-	unless iter goto iter_end
-	key = shift iter
+	unless it goto iter_end
+	key = shift it
 	replacement = iub[key]
 	# Ok, using a regex to match a single fixed character is probably excessive
 	# But it's what's wanted...

Modified: trunk/examples/tutorial/55_iterator.pir
==============================================================================
--- trunk/examples/tutorial/55_iterator.pir	Tue Jul 21 21:51:08 2009	(r40199)
+++ trunk/examples/tutorial/55_iterator.pir	Tue Jul 21 21:51:54 2009	(r40200)
@@ -17,15 +17,15 @@
 =cut
 
 .sub main :main
-    .local pmc myarray, iter
+    .local pmc myarray, it
 
     myarray = split " ", "foo bar baz boz"
 
-    iter = new ['Iterator'], myarray
+    it = iter myarray
   iter_loop:
-    unless iter goto iter_end
+    unless it goto iter_end
 
-    $P0 = shift iter
+    $P0 = shift it
     say $P0
 
     goto iter_loop


More information about the parrot-commits mailing list