*From*: "Beata Winnicka" <bfatyga@slab.cica.indiana.edu>*Date*: Thu, 23 Jun 94 08:42:46 -0500*To*: jlliu@ie.nsysu.edu.tw (Liu Je-Lian)*Subject*: Re:*Cc*: sage-bugs@cica.indiana.edu

You wrote: Dear Sir, Did anybody receive the mail I sent before that is about a problem of for loop? I cannot get the bounds of it with Sage++? The SgForStmt class cannot deal with the for loop in C well, right? If there is any method that I can get the bounds, please tell me. Best Regards, clliu clliu@alpha.ie.nsysu.edu.tw __________________________________________________________ Yes, we have received your email. A response was sent yesterday. In case it somehow got lost, below is a copy of that response. Following that copy is a patch for a bug in SgForStmt::end() and SgForStmt::step() methods. With this bug fix, you should be able to do what you wanted (i.e., extract lower and upper bound, and the step size from the "for" statement in C. --Beata ______________________________________ From: "Beata Winnicka" <bfatyga@slab.cica.indiana.edu> Date: Wed, 22 Jun 94 08:55:23 -0500 To: jlliu@ie.nsysu.edu.tw (Liu Je-Lian) Subject: Re: for loops Cc: sage-bugs@cica.indiana.edu Dear Liu, it is relatively straightforward to get the values you want from the expressions, for example, for the assignment expression you just need to check what is the value on the right-hand-side (using SgExpresion::rhs(); for the inequality case you need to distinguish between LT_OP and LE_OP; and for the step you need to take into account various ways in which it can be specified. All this can be done using methods of Sage++. I was somewhat surprised to hear that: "I can only get the expressions, but I cannot get the value of the bounds." The version of Sage that I am using has a bug in SgForStmt::end() and SgForStmt::step() methods. As a result I can only get SgForStmt::start() to work at the moment. (I am working on fixing this bug right now). Which version of Sage are you using? --Beata ______________________________ The patch for SgForStmt::end() and SgForStmt::step() Just replace the old code in lib/include/libSage++.h with the new code: inline SgExpression * SgForStmt::end() { PTR_LLND endExp; SgExpression *x; if (CurrentProject->Fortranlanguage()) { if ((BIF_LL1(thebif) != LLNULL) && (NODE_CODE(BIF_LL1(thebif)) == DDOT)) x = LlndMapping(NODE_OPERAND1(BIF_LL1(thebif))); else { x = NULL; SORRY; } } else /* BW, change contributed by Michael Golden */ { if (BIF_LL2(thebif) == LLNULL) x = NULL; else x = LlndMapping(BIF_LL2(thebif)); } return x; } inline SgExpression * SgForStmt::step() { PTR_LLND endExp; SgExpression *x; if (CurrentProject->Fortranlanguage()) { x = LlndMapping(BIF_LL2(thebif)); } else /* BW, change contributed by Michael Golden */ { if (BIF_LL3(thebif) == LLNULL) x = NULL; else x = LlndMapping(BIF_LL3(thebif)); } return x; }

- Prev:
**Re:** - Next:
**Re: for loops** - Index:
**Sage-bugs 1994 Mail Archive**