Replaced TIntermLoop::testFirst with TIntermLoop::loopType to clearly indicate which type of loop it is. In some cases it is not possble to differentiate between a for-loop and while-loop.
BUG=48
Review URL: http://codereview.appspot.com/3123041
git-svn-id: https://angleproject.googlecode.com/svn/trunk@482 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/intermediate.h b/src/compiler/intermediate.h
index dd269e1..1b08d73 100644
--- a/src/compiler/intermediate.h
+++ b/src/compiler/intermediate.h
@@ -262,30 +262,38 @@
//
// Handle for, do-while, and while loops.
//
+enum TLoopType {
+ ELoopFor,
+ ELoopWhile,
+ ELoopDoWhile,
+};
+
class TIntermLoop : public TIntermNode {
public:
- TIntermLoop(TIntermNode *init, TIntermNode* aBody, TIntermTyped* aTest, TIntermTyped* aTerminal, bool testFirst) :
- init(init),
- body(aBody),
- test(aTest),
- terminal(aTerminal),
- first(testFirst) { }
+ TIntermLoop(TLoopType aType,
+ TIntermNode *aInit, TIntermTyped* aCond, TIntermTyped* aExpr,
+ TIntermNode* aBody) :
+ type(aType),
+ init(aInit),
+ cond(aCond),
+ expr(aExpr),
+ body(aBody) { }
virtual TIntermLoop* getAsLoopNode() { return this; }
virtual void traverse(TIntermTraverser*);
- TIntermNode *getInit() { return init; }
- TIntermNode *getBody() { return body; }
- TIntermTyped *getTest() { return test; }
- TIntermTyped *getTerminal() { return terminal; }
- bool testFirst() { return first; }
+ TLoopType getType() const { return type; }
+ TIntermNode* getInit() { return init; }
+ TIntermTyped* getCondition() { return cond; }
+ TIntermTyped* getExpression() { return expr; }
+ TIntermNode* getBody() { return body; }
protected:
- TIntermNode *init;
- TIntermNode *body; // code to loop over
- TIntermTyped *test; // exit condition associated with loop, could be 0 for 'for' loops
- TIntermTyped *terminal; // exists for for-loops
- bool first; // true for while and for, not for do-while
+ TLoopType type;
+ TIntermNode* init; // for-loop initialization
+ TIntermTyped* cond; // loop exit condition
+ TIntermTyped* expr; // for-loop expression
+ TIntermNode* body; // loop body
};
//