for (int i = 0; i < mystmts.length; i++) {
visit(mystmts[i]);
}
} else if (stmt instanceof IASTForStatement) {
IASTForStatement fstmt = (IASTForStatement) stmt;
IASTStatement initializer = fstmt.getInitializerStatement();
String initVar;
ExprVisitor initExpr = new ExprVisitor();
ExprVisitor finalExpr = new ExprVisitor();
if (initializer instanceof IASTDeclarationStatement) {
IASTDeclarationStatement declaration = (IASTDeclarationStatement) initializer;
IASTSimpleDeclaration simple = (IASTSimpleDeclaration) (declaration.getDeclaration());
IASTDeclarator[] declarators = simple.getDeclarators();
initVar = declarators[0].getName().getRawSignature();
((IASTEqualsInitializer) (declarators[0].getInitializer())).getInitializerClause().accept(initExpr);
} else {
initVar = ((IASTBinaryExpression) (((IASTExpressionStatement) initializer)
.getExpression())).getOperand1().getRawSignature();
((IASTBinaryExpression) (((IASTExpressionStatement) initializer).getExpression())).getOperand2().accept(initExpr);
}
int forOperator = ((IASTBinaryExpression) (fstmt.getConditionExpression())).getOperator();
Expression LBExpr, UBExpr;
int stride = 1; //FIXME: ACTUALLY COMPUTE STRIDE
((IASTBinaryExpression) (fstmt.getConditionExpression())).getOperand2().accept(finalExpr);
//condition is <=
if (forOperator == IASTBinaryExpression.op_lessEqual){
LBExpr = initExpr.getExpr();
UBExpr = finalExpr.getExpr();
}
else if (forOperator == IASTBinaryExpression.op_lessThan){
LBExpr = initExpr.getExpr();
UBExpr = finalExpr.getExpr();;
UBExpr = UBExpr.sub(new Expression(stride));
}
else if (forOperator == IASTBinaryExpression.op_greaterEqual){
LBExpr = finalExpr.getExpr();
UBExpr = initExpr.getExpr();
}
else if (forOperator == IASTBinaryExpression.op_greaterThan){
LBExpr = finalExpr.getExpr();
LBExpr = LBExpr.add(new Expression(stride));
UBExpr = initExpr.getExpr();
}
else {
//CRASH HERE
throw new RuntimeException ("PARSER CAN'T HANDLE EXCEPTION");
}
//_iterList.add(initVar);
IASTExpression condition = ((IASTBinaryExpression) (fstmt.getConditionExpression())).getOperand2();
//if (condition instanceof IASTIdExpression){
// _paramList.add(condition.getRawSignature());
//}
Control forControl = new Control(initVar, LBExpr, UBExpr);
Statement forStmt = new Statement(forControl); //factory.create(fstmt, forControl);
if (!stmtStack.empty()) stmtStack.peek().Enclose(forStmt, elseFlagStack.peek());
stmtStack.push(forStmt); elseFlagStack.push(false);
visit(fstmt.getBody());
if (stmtStack.size() == 1) parent.Enclose(stmtStack.peek(), elseFlagStack.peek());
stmtStack.pop(); elseFlagStack.pop();
return PROCESS_SKIP;
} else if (stmt instanceof IASTIfStatement) {