in_oOpExp.getOperationName()));
in_oOpExp.setRight(
negateArithmeticalTCGOCLExpression(in_oOpExp.getRight()));
}
else {
TCGOCLOperation oOpLeftExp = (TCGOCLOperation)in_oOpExp.getLeft();
OCLTreeExpressionFindObjectVisitor oVisitor =
new OCLTreeExpressionFindObjectVisitor(in_oVariable);
OCLTreeExpressionIterator.run(oOpLeftExp.getLeft(), oVisitor);
// try to shift the variable to the left side of the left expression
// variable is on local right side of the left expression
// -> exchange on left hand side left and right
if(!oVisitor.isFound()) {
// exchange sides
TCGOCLExpression oLeftSide = oOpLeftExp.getLeft();
oOpLeftExp.setLeft(oOpLeftExp.getRight());
oOpLeftExp.setRight(oLeftSide);
// influence relation operator correspondingly
if(oOpLeftExp.getOperationName().equals("+") ||
oOpLeftExp.getOperationName().equals("*")) {
// nothing - written just for completeness
}
else if(oOpLeftExp.getOperationName().equals("-")) {
in_oOpExp.setOperationName(
sm_colCorrespondingRelations.get(
in_oOpExp.getOperationName()));
in_oOpExp.setRight(
TCGOCLExpressionHelperClass.negateArithmeticalTCGOCLExpression(
in_oOpExp.getRight()));
}
else if(oOpLeftExp.getOperationName().equals("/"))
{
// TODO #### Fallunterscheidung einbauen und evtl. mehrere m�gliche
// Ausdr�cke zur�ckgeben
}
// check again
OCLTreeExpressionIterator.run(oOpLeftExp.getLeft(), oVisitor);
}
// not "else" -> value is computed again at the last statement
// variable is on local left side of the left expression
// -> transfer local right side of left expression to the right expression
if(oVisitor.isFound()) {
TCGOCLExpression oLeftSide = oOpLeftExp.getLeft();
oOpLeftExp.setLeft(in_oOpExp.getRight());
in_oOpExp.setRight(oOpLeftExp);
in_oOpExp.setLeft(oLeftSide);
// exclude the case that we work with an unary minus or a not
if(!(oOpLeftExp.getRight() == null &&
(oOpLeftExp.getOperationName().equals("-") ||
oOpLeftExp.getOperationName().equals("not")))) {
oOpLeftExp.setOperationName(sm_colCorrespondingOperations.get(
oOpLeftExp.getOperationName()));
// multiplication or division with a negative number?
if((oOpLeftExp.getOperationName().compareTo("*") == 0) ||
(oOpLeftExp.getOperationName().compareTo("/") == 0)) {
// moved expression was negative
if(expressionIsNegative(oOpLeftExp.getRight()))
{
// exchange relation symbol
in_oOpExp.setOperationName(sm_colCorrespondingRelations.get(in_oOpExp.getOperationName()));
}
}