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; [StorableClass] public abstract class PopExpression : StatelessExpression { protected PopExpression() { } [StorableConstructor] protected PopExpression(bool deserializing) : base(deserializing) { } protected void Eval(IPushStack stack) { stack.Pop(); } } [StorableClass] [PushExpression(StackTypes.Integer, "INTEGER.POP", "Pops the top INTEGER item.")] public class IntegerPopExpression : PopExpression { public IntegerPopExpression() { } [StorableConstructor] protected IntegerPopExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.IntegerStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.IntegerStack); } } [StorableClass] [PushExpression(StackTypes.Float, "FLOAT.POP", "Pops the top FLOAT item.")] public class FloatPopExpression : PopExpression { public FloatPopExpression() { } [StorableConstructor] protected FloatPopExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.FloatStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.FloatStack); } } [StorableClass] [PushExpression(StackTypes.Boolean, "BOOLEAN.POP", "Pops the top BOOLEAN item.")] public class BooleanPopExpression : PopExpression { public BooleanPopExpression() { } [StorableConstructor] protected BooleanPopExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.BooleanStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.BooleanStack); } } [StorableClass] [PushExpression(StackTypes.Name, "NAME.POP", "Pops the top NAME item.")] public class NamePopExpression : PopExpression { public NamePopExpression() { } [StorableConstructor] protected NamePopExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.NameStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.NameStack); } } [StorableClass] [PushExpression(StackTypes.Exec, "EXEC.POP", "Pops the top EXEC item.", requiredBlockCount: 1)] public class ExecPopExpression : PopExpression { public ExecPopExpression() { } [StorableConstructor] protected ExecPopExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.ExecStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.ExecStack); } } [StorableClass] [PushExpression(StackTypes.Code, "CODE.POP", "Pops the top CODE item.")] public class CodePopExpression : PopExpression { public CodePopExpression() { } [StorableConstructor] protected CodePopExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.CodeStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.CodeStack); } } [StorableClass] [PushExpression(StackTypes.Char, "CHAR.POP", "Pops the top CHAR item.")] public class CharPopExpression : PopExpression { public CharPopExpression() { } [StorableConstructor] protected CharPopExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.CharStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.CharStack); } } [StorableClass] [PushExpression(StackTypes.String, "STRING.POP", "Pops the top STRING item.")] public class StringPopExpression : PopExpression { public StringPopExpression() { } [StorableConstructor] protected StringPopExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.StringStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.StringStack); } } [StorableClass] [PushExpression(StackTypes.IntegerVector, "INTEGER[].POP", "Pops the top INTEGER[] item.")] public class IntegerVectorPopExpression : PopExpression> { public IntegerVectorPopExpression() { } [StorableConstructor] protected IntegerVectorPopExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.IntegerVectorStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.IntegerVectorStack); } } [StorableClass] [PushExpression(StackTypes.FloatVector, "FLOAT[].POP", "Pops the top FLOAT[] item.")] public class FloatVectorPopExpression : PopExpression> { public FloatVectorPopExpression() { } [StorableConstructor] protected FloatVectorPopExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.FloatVectorStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.FloatVectorStack); } } [StorableClass] [PushExpression(StackTypes.BooleanVector, "BOOLEAN[].POP", "Pops the top BOOLEAN[] item.")] public class BooleanVectorPopExpression : PopExpression> { public BooleanVectorPopExpression() { } [StorableConstructor] protected BooleanVectorPopExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.BooleanVectorStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.BooleanVectorStack); } } [StorableClass] [PushExpression(StackTypes.StringVector, "STRING[].POP", "Pops the top STRING[] item.")] public class StringVectorPopExpression : PopExpression> { public StringVectorPopExpression() { } [StorableConstructor] protected StringVectorPopExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.StringVectorStack.IsEmpty; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.StringVectorStack); } } }