package code.instr;

import code.space.Computation;
import code.space.Space;
import code.stuff.Logger;
import code.stuff.Tracer;
import code.term.Term;

/**
 * Residuate the current computation. Since often this is the only instruction
 * of an array of instructions, see also Instruction.residuate.
 *
 * @author Sergio Antoy
 * @since June 17, 2003
 */

public class Residuate implements Instruction {
    private Residuate() {}
    public final static Residuate singleton = new Residuate();

    /**
     * A sequence of FLVM instructions that causes residuation.
     * Can be used to optimize Branch instructions.
     */
    public static final Instruction[] residuateSeq = { singleton, };

    public void execute(Computation computation) {
        if (Tracer.instruction) {
            Term current = Space.instance.current;
            Logger.logln("-C- " + computation.debug() +
                    " residuating on " + current);
        }
        computation.selfSetState(Computation.RESIDUATING);
    }

    public String printAsTxtLoadable() { return "Residuate"; }
}

