ControlFlow.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package processor;
  2. import codeline.CodeLine.BackwardAction;
  3. /**
  4. * specifies what should be done after executing a line of code.
  5. * @author kolja
  6. *
  7. */
  8. public class ControlFlow {
  9. public static final int STEP_INTO = 0;
  10. public static final int STEP_OVER = 1;
  11. public static final int CALL = 2;
  12. private int status;
  13. private PseudoCodeNode function;
  14. private PseudoCodeNode jumpBack;
  15. private BackwardAction reverse;
  16. /**
  17. * creates a new {@link ControlFlow} from a given status
  18. * @param status one of ControlFlow.STEP_INTO, ControlFlow.STEP_OVER or ControlFlow.CALL
  19. */
  20. public ControlFlow( int status )
  21. {
  22. this.status = status;
  23. function = null;
  24. jumpBack = null;
  25. reverse = null;
  26. }
  27. /**
  28. * creates a new {@link ControlFlow} that is a function call
  29. * @param functionNode the {@link PseudoCodeNode} of the function to call
  30. */
  31. public ControlFlow( PseudoCodeNode functionNode )
  32. {
  33. status = CALL;
  34. function = functionNode;
  35. jumpBack = null;
  36. reverse = null;
  37. }
  38. /*
  39. * Package Private from here on
  40. * This is wanted because the individual algorithms should not have access to these functions
  41. */
  42. void setJumpBack( PseudoCodeNode jB )
  43. {
  44. jumpBack = jB;
  45. }
  46. void setBackwardAction( BackwardAction bka )
  47. {
  48. reverse = bka;
  49. }
  50. void backward( Memory m )
  51. {
  52. if( reverse != null )
  53. reverse.backward( m );
  54. }
  55. PseudoCodeNode getJumpBack()
  56. {
  57. return jumpBack;
  58. }
  59. PseudoCodeNode getFunction()
  60. {
  61. return function;
  62. }
  63. int getStatus()
  64. {
  65. return status;
  66. }
  67. }