namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions { using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes; using HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter; using Stack; /// /// Tells whether that stack is empty. /// [StorableClass] public abstract class EmptyExpression : StatelessExpression { protected EmptyExpression() { } [StorableConstructor] protected EmptyExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return false; } public void Eval(IPushStack stack, IPushStack booleanStack) { booleanStack.Push(stack.IsEmpty); } } [StorableClass] [PushExpression( StackTypes.Exec, "EXEC.EMPTY", "Pushes TRUE onto the BOOLEAN stack if the EXEC stack is empty, otherwise FALSE.", StackTypes.Boolean)] public class ExecEmptyExpression : EmptyExpression { public ExecEmptyExpression() { } [StorableConstructor] protected ExecEmptyExpression(bool deserializing) : base(deserializing) { } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.ExecStack, interpreter.BooleanStack); } } [StorableClass] [PushExpression( StackTypes.Code, "CODE.EMPTY", "Pushes TRUE onto the BOOLEAN stack if the CODE stack is empty, otherwise FALSE.", StackTypes.Boolean)] public class CodeEmptyExpression : EmptyExpression { public CodeEmptyExpression() { } [StorableConstructor] protected CodeEmptyExpression(bool deserializing) : base(deserializing) { } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.CodeStack, interpreter.BooleanStack); } } [StorableClass] [PushExpression( StackTypes.Integer, "INTEGER.EMPTY", "Pushes TRUE onto the BOOLEAN stack if the INTEGER stack is empty, otherwise FALSE.", StackTypes.Boolean)] public class IntegerEmptyExpression : EmptyExpression { public IntegerEmptyExpression() { } [StorableConstructor] protected IntegerEmptyExpression(bool deserializing) : base(deserializing) { } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.IntegerStack, interpreter.BooleanStack); } } [StorableClass] [PushExpression( StackTypes.Float, "FLOAT.EMPTY", "Pushes TRUE onto the BOOLEAN stack if the FLOAT stack is empty, otherwise FALSE.", StackTypes.Boolean)] public class FloatEmptyExpression : EmptyExpression { public FloatEmptyExpression() { } [StorableConstructor] protected FloatEmptyExpression(bool deserializing) : base(deserializing) { } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.FloatStack, interpreter.BooleanStack); } } [StorableClass] [PushExpression( StackTypes.Boolean, "BOOLEAN.EMPTY", "Pushes TRUE onto the BOOLEAN stack if the BOOLEAN stack is empty, otherwise FALSE.")] public class BooleanEmptyExpression : EmptyExpression { public BooleanEmptyExpression() { } [StorableConstructor] protected BooleanEmptyExpression(bool deserializing) : base(deserializing) { } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.BooleanStack, interpreter.BooleanStack); } } [StorableClass] [PushExpression( StackTypes.Char, "CHAR.EMPTY", "Pushes TRUE onto the BOOLEAN stack if the CHAR stack is empty, otherwise FALSE.", StackTypes.Boolean)] public class CharEmptyExpression : EmptyExpression { public CharEmptyExpression() { } [StorableConstructor] protected CharEmptyExpression(bool deserializing) : base(deserializing) { } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.CharStack, interpreter.BooleanStack); } } [StorableClass] [PushExpression( StackTypes.String, "STRING.EMPTY", "Pushes TRUE onto the BOOLEAN stack if the STRING stack is empty, otherwise FALSE.", StackTypes.Boolean)] public class StringEmptyExpression : EmptyExpression { public StringEmptyExpression() { } [StorableConstructor] protected StringEmptyExpression(bool deserializing) : base(deserializing) { } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.StringStack, interpreter.BooleanStack); } } [StorableClass] [PushExpression( StackTypes.IntegerVector, "INTEGER[].EMPTY", "Pushes TRUE onto the BOOLEAN stack if the INTEGER[] stack is empty, otherwise FALSE.", StackTypes.Boolean)] public class IntegerVectorEmptyExpression : EmptyExpression { public IntegerVectorEmptyExpression() { } [StorableConstructor] protected IntegerVectorEmptyExpression(bool deserializing) : base(deserializing) { } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.IntegerVectorStack, interpreter.BooleanStack); } } [StorableClass] [PushExpression( StackTypes.FloatVector, "FLOAT[].EMPTY", "Pushes TRUE onto the BOOLEAN stack if the FLOAT[] stack is empty, otherwise FALSE.", StackTypes.Boolean)] public class FloatVectorEmptyExpression : EmptyExpression { public FloatVectorEmptyExpression() { } [StorableConstructor] protected FloatVectorEmptyExpression(bool deserializing) : base(deserializing) { } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.FloatVectorStack, interpreter.BooleanStack); } } [StorableClass] [PushExpression( StackTypes.BooleanVector, "BOOLEAN[].EMPTY", "Pushes TRUE onto the BOOLEAN stack if the BOOLEAN[] stack is empty, otherwise FALSE.", StackTypes.Boolean)] public class BooleanVectorEmptyExpression : EmptyExpression { public BooleanVectorEmptyExpression() { } [StorableConstructor] protected BooleanVectorEmptyExpression(bool deserializing) : base(deserializing) { } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.BooleanVectorStack, interpreter.BooleanStack); } } [StorableClass] [PushExpression( StackTypes.StringVector, "STRING[].EMPTY", "Pushes TRUE onto the BOOLEAN stack if the STRING[] stack is empty, otherwise FALSE.", StackTypes.Boolean)] public class StringVectorEmptyExpression : EmptyExpression { public StringVectorEmptyExpression() { } [StorableConstructor] protected StringVectorEmptyExpression(bool deserializing) : base(deserializing) { } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.StringVectorStack, interpreter.BooleanStack); } } [StorableClass] [PushExpression( StackTypes.Print, "PRINT.EMPTY", "Pushes TRUE onto the BOOLEAN stack if the PRINT stack is empty, otherwise FALSE.", StackTypes.Boolean)] public class PrintEmptyExpression : EmptyExpression { public PrintEmptyExpression() { } [StorableConstructor] protected PrintEmptyExpression(bool deserializing) : base(deserializing) { } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.PrintStack, interpreter.BooleanStack); } } }