package animation;

import java.util.Stack;

public abstract class CodeLine {

	protected interface BackwardAction
	{
		public void backward( Memory m );
	}
	
	protected Stack<BackwardAction> actions;
	protected int lineId;
	private static int nextLineId = 0;
	
	public CodeLine()
	{
		synchronized( CodeLine.class ) {
			lineId = nextLineId++;
		}
		actions = new Stack<BackwardAction>();
	}
	
    public abstract ControlFlow runForward( Memory m );
    
    public void runBackward( Memory m )
    {
    	if( actions.size() != 0 )
    	    actions.pop().backward( m );
    }
}
