Skip to content
Browse files

[C99] use the opcode 'iter' instead of a instantiation of 'Iterator'

  • Loading branch information...
1 parent 0aef655 commit 2f7f61b8e402662e34f919ede1ccff721161cbee @fperrad fperrad committed Jul 24, 2009
Showing with 55 additions and 60 deletions.
  1. +8 −8 src/CPP_ASTGrammar.tg
  2. +9 −10 src/CPP_PASTNodes.pir
  3. +7 −7 src/builtins/say.pir
  4. +7 −7 src/cpp/src/builtins/say.pir
  5. +24 −28 src/preamble
View
16 src/CPP_ASTGrammar.tg
@@ -25,11 +25,11 @@ transform result (C99::CPP::ASTGrammar::group) :language('PIR') {
unless $I0 goto err_no_tree
$P0 = node['group_line']
- .local pmc iter
- iter = new Iterator, $P0
+ .local pmc it
+ it = iter $P0
iter_loop:
- unless iter, iter_end
- $P1 = shift iter
+ unless it goto iter_end
+ $P1 = shift it
child = tree.get('result', $P1, 'C99::CPP::ASTGrammar::group_line')
result.add_child(child)
goto iter_loop
@@ -96,14 +96,14 @@ transform result (C99::CPP::ASTGrammar::if_section) :language('PIR') {
child = tree.get('result', $P0, 'C99::CPP::ASTGrammar::if_group')
result.add_child(child)
- .local pmc iter
+ .local pmc it
$I0 = defined node['elif_group']
unless $I0 goto else_group
$P0 = node['elif_group']
- iter = new Iterator, $P0
+ it = iter $P0
iter_loop:
- unless iter, iter_end
- $P1 = shift iter
+ unless it goto iter_end
+ $P1 = shift it
child = tree.get('result', $P1, 'C99::CPP::ASTGrammar::elif_group')
result.add_child(child)
goto iter_loop
View
19 src/CPP_PASTNodes.pir
@@ -77,11 +77,11 @@ needed for C99. The currently defined ast nodes:
setattribute self, 'children', children
if null adverbs goto end
- .local pmc iter
- iter = new .Iterator, adverbs
+ .local pmc it
+ it = iter adverbs
iter_loop:
- unless iter goto iter_end
- $S0 = shift iter
+ unless it goto iter_end
+ $S0 = shift it
if $S0 == 'XXX' goto iter_loop
$P0 = iter[$S0]
$P1 = find_method self, $S0
@@ -164,8 +164,7 @@ needed for C99. The currently defined ast nodes:
.sub 'child_iter' :method
$P0 = getattribute self, 'children'
- $P1 = new .Iterator, $P0
- $P1 = 0
+ $P1 = iter $P0
.return ($P1)
.end
@@ -237,15 +236,15 @@ counting at 10 (so that the values 0..9 can be considered "safe").
(subindent, indent) = dumper.'newIndent'()
print '=> { '
-.local pmc attrlist, iter
+ .local pmc attrlist, it
$S0 = self.'__dumplist'()
attrlist = split ' ', $S0
- iter = new .Iterator, attrlist
+ it = iter attrlist
iter_loop:
- unless iter goto iter_end
+ unless it goto iter_end
.local string attrname
.local pmc val
- attrname = shift iter
+ attrname = shift it
val = getattribute self, attrname
print "\n"
print subindent
View
14 src/builtins/say.pir
@@ -10,11 +10,11 @@ say.pir -- simple implementation of a say function
.sub 'say'
.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:
@@ -25,10 +25,10 @@ say.pir -- simple implementation of a say function
.sub 'printf'
.param pmc format
.param pmc args :slurpy
- .local pmc iter
- iter = new 'Iterator', args
+ .local pmc it
+ it = iter args
iter_loop:
- unless iter goto iter_end
+ unless it goto iter_end
goto iter_loop
iter_end:
.end
View
14 src/cpp/src/builtins/say.pir
@@ -10,11 +10,11 @@ say.pir -- simple implementation of a say function
.sub 'say'
.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:
@@ -25,10 +25,10 @@ say.pir -- simple implementation of a say function
.sub 'printf'
.param pmc format
.param pmc args :slurpy
- .local pmc iter
- iter = new 'Iterator', args
+ .local pmc it
+ it = iter args
iter_loop:
- unless iter goto iter_end
+ unless it goto iter_end
goto iter_loop
iter_end:
.end
View
52 src/preamble
@@ -11,64 +11,60 @@
.endm
.macro dump_root
- .local string it
+ .local string item
.local pmc ns
ns = get_root_namespace [ 'parrot'; 'Cardinal::Grammar' ]
- .local pmc iter
- iter = new 'Iterator', ns
- set iter, 0
+ .local pmc it
+ it = iter ns
.label $iter_loop:
- unless iter, .$iter_end
- shift it, iter
- print it
+ unless it goto .$iter_end
+ item = shift it
+ print item
print "\n"
goto .$iter_loop
.label $iter_end:
.endm
.macro dump_hll
- .local string it
+ .local string item
.local pmc ns
ns = get_hll_namespace
- .local pmc iter
- iter = new 'Iterator', ns
- set iter, 0
+ .local pmc it
+ it = iter ns
.label $iter_loop:
- unless iter, .$iter_end
- shift it, iter
- print it
+ unless it goto .$iter_end
+ item = shift it
+ print item
print "\n"
goto .$iter_loop
.label $iter_end:
.endm
.macro dump_hll2
- .local string it
+ .local string item
.local pmc ns
ns = get_hll_namespace
- .local pmc iter
- iter = new 'Iterator', ns
- set iter, 0
+ .local pmc it
+ it = iter ns
.label $iter_loop:
- unless iter, .$iter_end
- shift it, iter
- print it
+ unless it goto .$iter_end
+ item = shift it
+ print item
print "\n"
goto .$iter_loop
.label $iter_end:
.endm
.macro dump_current
- .local string it
+ .local string item
.local pmc ns
ns = get_namespace
- .local pmc iter
- iter = new 'Iterator', ns
- set iter, 0
+ .local pmc it
+ it = iter ns
.label $iter_loop:
- unless iter, .$iter_end
- shift it, iter
- print it
+ unless it goto .$iter_end
+ item = shift it
+ print item
print "\n"
goto .$iter_loop
.label $iter_end:

0 comments on commit 2f7f61b

Please sign in to comment.
Something went wrong with that request. Please try again.