|
From: <net...@us...> - 2002-12-30 13:59:21
|
Update of /cvsroot/cpptool/rfta/src/rfta
In directory sc8-pr-cvs1:/tmp/cvs-serv8998/rfta/src/rfta
Modified Files:
InlineTempRefactoring.cpp
Log Message:
-- handling for expr-lists added
Index: InlineTempRefactoring.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/InlineTempRefactoring.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** InlineTempRefactoring.cpp 30 Dec 2002 10:44:08 -0000 1.3
--- InlineTempRefactoring.cpp 30 Dec 2002 13:59:18 -0000 1.4
***************
*** 143,157 ****
{
bool go_deeper = false;
do {
go_deeper = false;
if (!parentExpr->hasProperty(ASTNodeProperties::expressionTypeProperty))
{
! // call mutator on this expression:
ParseContext context( sourceNode_ );
ExpressionOperationMutator mutator( context, parentExpr, sourceNode_ );
mutator.mutate();
! // check if no expression type was added:
if (!parentExpr->hasProperty(ASTNodeProperties::expressionTypeProperty))
! break;
}
--- 143,162 ----
{
bool go_deeper = false;
+ // this loop does implement lazy parsing of the expression where the
+ // temporary variable occures. It does parse step by step only these sub
+ // parts that are needed to be anlysed (where the variable is placed)
do {
go_deeper = false;
+
+ // check if the expression has been parsed allready
if (!parentExpr->hasProperty(ASTNodeProperties::expressionTypeProperty))
{
! // call mutator that parses this expression:
ParseContext context( sourceNode_ );
ExpressionOperationMutator mutator( context, parentExpr, sourceNode_ );
mutator.mutate();
! // check if expression type was added (the parser has detected a type):
if (!parentExpr->hasProperty(ASTNodeProperties::expressionTypeProperty))
! break; // it has not... so we don't know if it is an assignment
}
***************
*** 160,173 ****
if (exprType->getType() == ASTNodeTypes::assignmentExpression)
{
! // find the first child that is <expression>
int idx;
for (idx=0;idx<parentExpr->getChildCount();idx++)
if (parentExpr->getChildAt(idx)->getType()==ASTNodeTypes::expression)
break;
! // check if localVariable is on the left hand side:
ASTNodePtr left = parentExpr->getChildAt(idx);
SourceRange varRange = (*it)->getRange();
SourceRange leftRange = left->getRange();
if (leftRange.contains(varRange))
throw RefactoringError( RefactoringError::variableIsAssigned );
else
--- 165,181 ----
if (exprType->getType() == ASTNodeTypes::assignmentExpression)
{
! // find the first child that is an <expression>
int idx;
for (idx=0;idx<parentExpr->getChildCount();idx++)
if (parentExpr->getChildAt(idx)->getType()==ASTNodeTypes::expression)
break;
! // check if localVariable is on the left hand side of the assignment:
ASTNodePtr left = parentExpr->getChildAt(idx);
SourceRange varRange = (*it)->getRange();
SourceRange leftRange = left->getRange();
+
if (leftRange.contains(varRange))
+ // @todo: if the expression parser has been extended we need
+ // to check here, if the assignment is really done to the variable
throw RefactoringError( RefactoringError::variableIsAssigned );
else
***************
*** 175,178 ****
--- 183,210 ----
parentExpr = parentExpr->getChildAt(idx+1);
go_deeper = true;
+ }
+ }
+ // check if it is an expression-list
+ if (exprType->getType() == ASTNodeTypes::expressionList)
+ {
+ // find the first child that is an <expression>
+ int idx;
+ for (idx=0;idx<parentExpr->getChildCount();idx++)
+ if (parentExpr->getChildAt(idx)->getType()==ASTNodeTypes::expression)
+ break;
+ while (idx<parentExpr->getChildCount())
+ {
+ // check if localVariable is on the left hand side of the assignment:
+ ASTNodePtr elem = parentExpr->getChildAt(idx);
+ SourceRange varRange = (*it)->getRange();
+ SourceRange elemRange = elem->getRange();
+
+ if (elemRange.contains(varRange))
+ {
+ parentExpr = parentExpr->getChildAt(idx);
+ go_deeper = true;
+ break;
+ }
+ idx++;
}
}
|