[Prev][Next][Index]
No Subject
- From: lzq@pact97b.hit.edu.cn
- Date: Wed, 6 May 1998 21:27:08 +0900
- To: sage-bugs@cica.indiana.edu
- Sender: owner-sage-bugs@extreme.indiana.edu
Hi Sir:
I have some trouble in using sage tools to programming. The trouble is:
When I insert a IfStatement using sage like insert the following statement:
if (a == 1) { a = a + 1; a = a - 1;}
and when finishing insert, I unparse the DEP file and the output is very right.
But the trouble come, when I want to insert another if after the if statement
I insert just now, and unparse it, but the output shows the second if statement
I inserted was inserted after the main statement. when I insert the second If
Statement, I am very sure that I insert the second if statement just after the
first if statment, but the answer is not like this. Would you tell there are
some problem when I insert the first if statement? I say like this just because
I can insert the if statement after another if statement if the if statement is
is originaly in the dep file. So I think I have some wrong step in insert the
if statement.
The program I insert the first if statement like this:
(I insert the if statement before the statement *s):
SgSymbol *a;
SgVarRefExp *var;
a = new SgVariableSymb("a",*SgTypeInt());
var = new SgVarRefExp(*a);
SgValueExp t(1);
SgIfStmt *aif;
SgStatement *truebody,themain;
themain = f->mainProgram(); //f is : SgFile *f;
truebody = NULL;
aif = new SgIfStmt(SgEqOp(*var,t),*truebody);
aif->setControlParent(*themain);
s->insertStmtBefore(*aif); //s is the statement where the if statement should insert before
//the next is to insert the true body;
SgStatement *first,*second;
first = new SgCExpStmt(SgEqOp(*var,*var+t));
first->setControlParent(*aif);
second = new SgCExpStmt(SgEqOp(*var,*var-t));
second->setControlParent(*aif);
first->setLexNext(*second);
aif->replaceTrueBody(*first);
//up to here, the first if statement already inserted!
//if I add another if statement like follow
s->insertStmtBefore(*aif);
//then the second if statement is not follow the first statement but follow the main statement!
//what is the matter???
Thank you very much.
I am very eager to get your hand!