/*
 * This file is released under terms of BSD license
 * See LICENSE file for more information
 */

package cx2x.xcodeml.xelement;

/**
 * A XloopIterationRange represents the elements parts of the iteration in a do
 * statement (induction variable, lower bound, upper bound, step)
 *
 * @author clementval
 */

public class XloopIterationRange {
  private final XindexRange _indexRange;
  private final Xvar _inductionVariable;

  public XloopIterationRange(Xvar inductionVar, XindexRange range){
    _inductionVariable = inductionVar;
    _indexRange = range;
  }

  public Xvar getInductionVar(){
    return _inductionVariable;
  }

  public XindexRange getIndexRange(){
    return _indexRange;
  }

  /**
   * Compare this loopIterationRange with the given one. Return true if all the
   * internal variable of the loopIterationRange are identical.
   * @param other The other object to be checked with.
   * @return True if the two loop iteration range are identical. False
   * otherwise.
   */
  public boolean isFullyIdentical(XloopIterationRange other){
    if(!getInductionVar().getValue().equals(other.getInductionVar().getValue())){
      return false;
    }
    return getIndexRange().equals(other.getIndexRange());
  }

  /**
   * Get a string representation of the iteration range.
   * @return A string representing the iteration range (e.g. i=1,10,1)
   */
  public String toString() {
    return getInductionVar().getValue() + "="
      + getIndexRange().getLowerBound().getValue() + ","
      + getIndexRange().getUpperBound().getValue() + ","
      + getIndexRange().getStep().getValue();
  }

  /**
   * Clone the current loop iteration range object.
   * @return A new XloopIterationRange that is the clone of the current one.
   */
  public XloopIterationRange cloneObject(){
    Xvar tmpVar = _inductionVariable.cloneObject();
    XindexRange tmpRange = _indexRange.cloneObject();
    return new XloopIterationRange(tmpVar, tmpRange);
  }
}

@@ -1220,32 +1220,666 @@
 xRange());%0A  %7D%0A%0A
+  public boolean isIdenticalBesidesLowerBound(XloopIterationRange other)%7B%0A    if(!getInductionVar().getValue().equals(other.getInductionVar().getValue()))%7B%0A      return false;%0A    %7D%0A%0A    if(getIndexRange().isAssumedShape()%0A        && other.getIndexRange().isAssumedShape())%7B%0A      return true;%0A    %7D%0A%0A    if (!getIndexRange().getUpperBound().equals(%0A        other.getIndexRange().getUpperBound()))%0A    %7B%0A      return false;%0A    %7D%0A%0A    // step is optional%0A    return getIndexRange().getStep() == null &&%0A        other.getIndexRange().getStep() == null %7C%7C%0A        getIndexRange().getStep().equals(other.getIndexRange().getStep());%0A  %7D%0A%0A
   /**%0A   * Get a

Add partial equality check