package ac.essex.gp.nodes.logic;

import ac.essex.gp.params.NodeParams;
import ac.essex.gp.util.DataStack;
import ac.essex.gp.tree.Node;

/**
 * Performs a NOT operation on a boolean value.
 *
 * @author Olly Oechsle, University of Essex, Date: 02-Apr-2007
 * @version 1.0
 */
public class NOT extends Node {

    public NOT() {
        super(1);
    }

    public int getReturnType() {
        return NodeParams.BOOLEAN;
    }

    public int getChildType(int index) {
        return NodeParams.BOOLEAN;
    }

    public double execute(DataStack data) {
        data.value = child[0].execute(data) != 1? 1 : 0;
        return debugger.record(data.value);
    }

    public String toJava() {
        return "!" + child[0].getName();
    }

}
