package ec.app.semanticGP.func.logic;

import library.semantics.BitSet;
import ec.gp.semantic.BooleanSemantics;
import ec.gp.semantic.ISemantics;
import ec.gp.semantic.func.UnaryNode;

public final class Inv extends UnaryNode<Boolean> {
	
	@Override
	public String toString() {
		return "!";
	}
	
	@Override
	protected ISemantics execute(ISemantics... arguments) {
		BitSet semantics = (BitSet) ((BitSet) arguments[0].getValue()).clone();
		semantics.flip(0, semantics.length());
		
		return new BooleanSemantics(semantics);
	}
	
	@Override
	public Boolean[] invert(Boolean output, int missingArgIdx, Boolean... restOfArguments) {
		return output ? Inversions.FALSE : Inversions.TRUE;
		//return !output ? Inversions.TRUE : Inversions.FALSE;
		//return new Boolean[] { !output };
	}
}
