package jetbrains.mps.lang.dataFlow.framework;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import jetbrains.mps.lang.dataFlow.framework.instructions.Instruction;
import java.util.List;

@GeneratedClass(node = "r:3dddb2c7-b2ba-4381-896a-2e702ca1fb6e(jetbrains.mps.lang.dataFlow.framework)/4074113095384028777", model = "r:3dddb2c7-b2ba-4381-896a-2e702ca1fb6e(jetbrains.mps.lang.dataFlow.framework)")
public class ProgramState {
  private Instruction myInstruction;
  private boolean myReturnMode;
  public ProgramState(Instruction instruction, boolean returnMode) {
    myInstruction = instruction;
    myReturnMode = returnMode;
  }
  public Instruction getInstruction() {
    return myInstruction;
  }
  public boolean isReturnMode() {
    return myReturnMode;
  }
  public boolean isStart() {
    return !(isReturnMode()) && myInstruction.isStart();
  }
  public List<ProgramState> succ() {
    return myInstruction.succ(this);
  }
  public List<ProgramState> pred() {
    return myInstruction.pred(this);
  }
  public int getIndex() {
    if (myReturnMode) {
      return myInstruction.getIndex() << 1;
    } else {
      return (myInstruction.getIndex() << 1) + 1;
    }
  }
  public String toString() {
    return "(state " + myInstruction + ", " + myReturnMode + ")";
  }
  public boolean equals(Object obj) {
    if (!(obj instanceof ProgramState)) {
      return false;
    }
    ProgramState s = (ProgramState) obj;
    return s.getIndex() == getIndex();
  }
  public int hashCode() {
    return getIndex();
  }
}
