diff options
author | Rüdiger Timm <rt@openoffice.org> | 2005-01-28 15:06:35 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2005-01-28 15:06:35 +0000 |
commit | c115c0a79aa576e695801aa00527c22af172572a (patch) | |
tree | 5ea9468bd3a15e343862326a667c2a4b728dec10 | |
parent | 375fe0fa9a2f158dff6a12c2b5eb77ea12b817f8 (diff) |
INTEGRATION: CWS ab13fixes (1.2.264); FILE MERGED
2005/01/17 16:01:52 ab 1.2.264.1: #118116# Parse for each
-rw-r--r-- | basic/source/comp/loops.cxx | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/basic/source/comp/loops.cxx b/basic/source/comp/loops.cxx index 9f631f2a4f2d..0f39e17bea3c 100644 --- a/basic/source/comp/loops.cxx +++ b/basic/source/comp/loops.cxx @@ -2,9 +2,9 @@ * * $RCSfile: loops.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mh $ $Date: 2001-10-17 18:53:05 $ + * last change: $Author: rt $ $Date: 2005-01-28 16:06:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -238,29 +238,45 @@ void SbiParser::While() void SbiParser::For() { + bool bForEach = ( Peek() == EACH ); + if( bForEach ) + Next(); SbiExpression aLvalue( this, SbOPERAND ); aLvalue.Gen(); // Variable auf dem Stack - TestToken( EQ ); - SbiExpression aStartExpr( this ); - aStartExpr.Gen(); // Startausdruck auf dem Stack - TestToken( TO ); - SbiExpression aStopExpr( this ); - aStopExpr.Gen(); // Endausdruck auf dem Stack - if( Peek() == STEP ) + + if( bForEach ) { - Next(); - SbiExpression aStepExpr( this ); - aStepExpr.Gen(); + TestToken( _IN_ ); + SbiExpression aCollExpr( this, SbOPERAND ); + aCollExpr.Gen(); // Colletion var to for stack + TestEoln(); + aGen.Gen( _INITFOREACH ); } else { - SbiExpression aOne( this, 1, SbxINTEGER ); - aOne.Gen(); + TestToken( EQ ); + SbiExpression aStartExpr( this ); + aStartExpr.Gen(); // Startausdruck auf dem Stack + TestToken( TO ); + SbiExpression aStopExpr( this ); + aStopExpr.Gen(); // Endausdruck auf dem Stack + if( Peek() == STEP ) + { + Next(); + SbiExpression aStepExpr( this ); + aStepExpr.Gen(); + } + else + { + SbiExpression aOne( this, 1, SbxINTEGER ); + aOne.Gen(); + } + TestEoln(); + // Der Stack hat jetzt 4 Elemente: Variable, Start, Ende, Inkrement + // Startwert binden + aGen.Gen( _INITFOR ); } - TestEoln(); - // Der Stack hat jetzt 4 Elemente: Variable, Start, Ende, Inkrement - // Startwert binden - aGen.Gen( _INITFOR ); + USHORT nLoop = aGen.GetPC(); // Test durchfuehren, evtl. Stack freigeben USHORT nEndTarget = aGen.Gen( _TESTFOR, 0 ); @@ -273,7 +289,7 @@ void SbiParser::For() { SbiExpression aVar( this, SbOPERAND ); if( aVar.GetRealVar() != aLvalue.GetRealVar() ) - Error( SbERR_EXPECTED, aVar.GetRealVar()->GetName() ); + Error( SbERR_EXPECTED, aLvalue.GetRealVar()->GetName() ); } aGen.BackChain( nEndTarget ); CloseBlock(); |