Author: pmichaud
Date: Tue Dec 23 11:01:07 2008
New Revision: 34282
Modified:
branches/pctloop2/compilers/pct/src/PAST/Compiler.pir
Log:
[pct]: Move repeat_until to use the loop_gen code.
Modified: branches/pctloop2/compilers/pct/src/PAST/Compiler.pir
==============================================================================
--- branches/pctloop2/compilers/pct/src/PAST/Compiler.pir (original)
+++ branches/pctloop2/compilers/pct/src/PAST/Compiler.pir Tue Dec 23
11:01:07 2008
@@ -1268,10 +1268,12 @@
.local pmc testpost, prepost, bodypost
.local string testop
+ .local int bodyfirst
testop = options['testop']
testpost = options['test']
prepost = options['pre']
bodypost = options['body']
+ bodyfirst = options['bodyfirst']
if testop goto have_testop
testop = 'unless'
@@ -1281,6 +1283,9 @@
$P0 = get_hll_global ['POST'], 'Ops'
ops = $P0.'new'()
+ unless bodyfirst goto bodyfirst_done
+ ops.'push_pirop'('goto', redolabel)
+ bodyfirst_done:
ops.'push'(testlabel)
if null testpost goto test_done
ops.'push'(testpost)
@@ -1328,9 +1333,11 @@
.local string testop
testop = options['testop']
+ .local int bodyfirst
+ bodyfirst = options['bodyfirst']
.local pmc ops
- ops = self.'loop_gen'('testop'=>testop, 'test'=>exprpost, 'body'=>bodypost)
+ ops = self.'loop_gen'('testop'=>testop, 'test'=>exprpost,
'body'=>bodypost, 'bodyfirst'=>bodyfirst)
ops.'result'(exprpost)
ops.'node'(node)
.return (ops)
@@ -1342,6 +1349,12 @@
.tailcall self.'while'(node, options :flat :named, 'testop'=>'if')
.end
+.sub 'repeat_until' :method :multi(_, ['PAST';'Op'])
+ .param pmc node
+ .param pmc options :slurpy :named
+ .tailcall self.'while'(node, options :flat :named, 'testop'=>'if',
'bodyfirst'=>1)
+.end
+
=item repeat_while(PAST::Op node)
@@ -1397,12 +1410,6 @@
.return (ops)
.end
-.sub 'repeat_until' :method :multi(_, ['PAST';'Op'])
- .param pmc node
- .param pmc options :slurpy :named
- .tailcall self.'repeat_while'(node, options :flat :named)
-.end
-
=item for(PAST::Op node)