package animation;

import animation.CodeLine.BackwardAction;

public class ControlFlow {
    public static final int STEP_INTO = 0;
    public static final int STEP_OVER = 1;
    public static final int CALL = 2;
    
    private int status;
    private PseudoCodeNode function;
    private PseudoCodeNode jumpBack;
    private BackwardAction reverse;
    
    public ControlFlow( int status )
    {
        this.status = status;
        function = null;
        jumpBack = null;
        reverse = null;
    }
    
    public ControlFlow( PseudoCodeNode functionNode )
    {
    	status = CALL;
    	function = functionNode;
        jumpBack = null;
        reverse = null;
    }
    
    /*
     * Package Private from here on
     * This is wanted because the individual algorithms should not have access to these functions
     */
    
    void setJumpBack( PseudoCodeNode jB )
    {
        jumpBack = jB;
    }
    
    void setBackwardAction( BackwardAction bka )
    {
        reverse = bka;
    }
    
    void backward( Memory m )
    {
        if( reverse != null )
            reverse.backward( m );
    }
    
    PseudoCodeNode getJumpBack()
    {
        return jumpBack;
    }
    
    PseudoCodeNode getFunction()
    {
    	return function;
    }
    
    int getStatus()
    {
        return status;
    }
}
