namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions { using System.Collections.Generic; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes; using Interpreter; using Stack; /// /// Empties the given stack. /// /// Stacktype [StorableClass] public abstract class FlushExpression : StatelessExpression { protected FlushExpression() { } [StorableConstructor] protected FlushExpression(bool deserializing) : base(deserializing) { } protected void Eval(IPushStack stack) { stack.Clear(); } } [PushExpression( StackTypes.Integer, "INTEGER.FLUSH", "Empties the INTEGER stack.")] [StorableClass] public class IntegerFlushExpression : FlushExpression { public IntegerFlushExpression() { } [StorableConstructor] protected IntegerFlushExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.IntegerStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.IntegerStack); } } [PushExpression( StackTypes.Float, "FLOAT.FLUSH", "Empties the FLOAT stack.")] [StorableClass] public class FloatFlushExpression : FlushExpression { public FloatFlushExpression() { } [StorableConstructor] protected FloatFlushExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.FloatStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.FloatStack); } } [PushExpression( StackTypes.Boolean, "BOOLEAN.FLUSH", "Empties the BOOLEAN stack.")] [StorableClass] public class BooleanFlushExpression : FlushExpression { public BooleanFlushExpression() { } [StorableConstructor] protected BooleanFlushExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.BooleanStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.BooleanStack); } } [PushExpression( StackTypes.Name, "NAME.FLUSH", "Empties the NAME stack.")] [StorableClass] public class NameFlushExpression : FlushExpression { public NameFlushExpression() { } [StorableConstructor] protected NameFlushExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.NameStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.NameStack); } } [PushExpression( StackTypes.Exec, "EXEC.FLUSH", "Empties the EXEC stack.")] [StorableClass] public class ExecFlushExpression : FlushExpression { public ExecFlushExpression() { } [StorableConstructor] protected ExecFlushExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.ExecStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.ExecStack); } } [PushExpression( StackTypes.Code, "CODE.FLUSH", "Empties the CODE stack.")] [StorableClass] public class CodeFlushExpression : FlushExpression { public CodeFlushExpression() { } [StorableConstructor] protected CodeFlushExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.CodeStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.CodeStack); } } [PushExpression( StackTypes.Char, "CHAR.FLUSH", "Empties the CHAR stack.")] [StorableClass] public class CharFlushExpression : FlushExpression { public CharFlushExpression() { } [StorableConstructor] protected CharFlushExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.CharStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.CharStack); } } [PushExpression( StackTypes.String, "STRING.FLUSH", "Empties the STRING stack.")] [StorableClass] public class StringFlushExpression : FlushExpression { public StringFlushExpression() { } [StorableConstructor] protected StringFlushExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.StringStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.StringStack); } } [PushExpression( StackTypes.IntegerVector, "INTEGER[].FLUSH", "Empties the INTEGER[] stack.")] [StorableClass] public class IntegerVectorFlushExpression : FlushExpression> { public IntegerVectorFlushExpression() { } [StorableConstructor] protected IntegerVectorFlushExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.IntegerVectorStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.IntegerVectorStack); } } [PushExpression( StackTypes.FloatVector, "FLOAT[].FLUSH", "Empties the FLOAT[] stack.")] [StorableClass] public class FloatVectorFlushExpression : FlushExpression> { public FloatVectorFlushExpression() { } [StorableConstructor] protected FloatVectorFlushExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.FloatVectorStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.FloatVectorStack); } } [PushExpression( StackTypes.BooleanVector, "BOOLEAN[].FLUSH", "Empties the BOOLEAN[] stack.")] [StorableClass] public class BooleanVectorFlushExpression : FlushExpression> { public BooleanVectorFlushExpression() { } [StorableConstructor] protected BooleanVectorFlushExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.BooleanVectorStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.BooleanVectorStack); } } [PushExpression( StackTypes.StringVector, "STRING[].FLUSH", "Empties the STRING[] stack.")] [StorableClass] public class StringVectorFlushExpression : FlushExpression> { public StringVectorFlushExpression() { } [StorableConstructor] protected StringVectorFlushExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.StringVectorStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.StringVectorStack); } } }