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 RotateExpression : StatelessExpression { protected RotateExpression() { } [StorableConstructor] protected RotateExpression(bool deserializing) : base(deserializing) { } protected void Eval(IPushStack stack) { stack.Swap(3); } } [PushExpression( StackTypes.Integer, "INTEGER.ROT", "Rotates the top 3 items of the INTEGER stack clockwise.")] [StorableClass] public class IntegerRotateExpression : RotateExpression { public IntegerRotateExpression() { } [StorableConstructor] protected IntegerRotateExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.IntegerStack.Count < 3; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.IntegerStack); } } [PushExpression( StackTypes.Float, "FLOAT.ROT", "Rotates the top 3 items of the FLOAT stack clockwise.")] [StorableClass] public class FloatRotateExpression : RotateExpression { public FloatRotateExpression() { } [StorableConstructor] protected FloatRotateExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.FloatStack.Count < 3; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.FloatStack); } } [PushExpression( StackTypes.Boolean, "BOOLEAN.ROT", "Rotates the top 3 items of the BOOLEAN stack clockwise.")] [StorableClass] public class BooleanRotateExpression : RotateExpression { public BooleanRotateExpression() { } [StorableConstructor] protected BooleanRotateExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.BooleanStack.Count < 3; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.BooleanStack); } } [PushExpression( StackTypes.Name, "NAME.ROT", "Rotates the top 3 items of the NAME stack clockwise.")] [StorableClass] public class NameRotateExpression : RotateExpression { public NameRotateExpression() { } [StorableConstructor] protected NameRotateExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.NameStack.Count < 3; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.NameStack); } } [PushExpression( StackTypes.Exec, "EXEC.ROT", "Rotates the top 3 items of the EXEC stack clockwise.", requiredBlockCount: 3)] [StorableClass] public class ExecRotateExpression : RotateExpression { public ExecRotateExpression() { } [StorableConstructor] protected ExecRotateExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.ExecStack.Count < 3; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.ExecStack); } } [PushExpression( StackTypes.Code, "CODE.ROT", "Rotates the top 3 items of the CODE stack clockwise.")] [StorableClass] public class CodeRotateExpression : RotateExpression { public CodeRotateExpression() { } [StorableConstructor] protected CodeRotateExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.CodeStack.Count < 3; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.CodeStack); } } [PushExpression( StackTypes.Char, "CHAR.ROT", "Rotates the top 3 items of the CHAR stack clockwise.")] [StorableClass] public class CharRotateExpression : RotateExpression { public CharRotateExpression() { } [StorableConstructor] protected CharRotateExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.CharStack.Count < 3; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.CharStack); } } [PushExpression( StackTypes.String, "STRING.ROT", "Rotates the top 3 items of the STRING stack clockwise.")] [StorableClass] public class StringRotateExpression : RotateExpression { public StringRotateExpression() { } [StorableConstructor] protected StringRotateExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.StringStack.Count < 3; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.StringStack); } } [PushExpression( StackTypes.IntegerVector, "INTEGER[].ROT", "Rotates the top 3 items of the INTEGER[] stack clockwise.")] [StorableClass] public class IntegerVectorRotateExpression : RotateExpression> { public IntegerVectorRotateExpression() { } [StorableConstructor] protected IntegerVectorRotateExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.IntegerVectorStack.Count < 3; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.IntegerVectorStack); } } [PushExpression( StackTypes.FloatVector, "FLOAT[].ROT", "Rotates the top 3 items of the FLOAT[] stack clockwise.")] [StorableClass] public class FloatVectorRotateExpression : RotateExpression> { public FloatVectorRotateExpression() { } [StorableConstructor] protected FloatVectorRotateExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.FloatVectorStack.Count < 3; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.FloatVectorStack); } } [PushExpression( StackTypes.BooleanVector, "BOOLEAN[].ROT", "Rotates the top 3 items of the BOOLEAN[] stack clockwise.")] [StorableClass] public class BooleanVectorRotateExpression : RotateExpression> { public BooleanVectorRotateExpression() { } [StorableConstructor] protected BooleanVectorRotateExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.BooleanVectorStack.Count < 3; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.BooleanVectorStack); } } [PushExpression( StackTypes.StringVector, "STRING[].ROT", "Rotates the top 3 items of the STRING[] stack clockwise.")] [StorableClass] public class StringVectorRotateExpression : RotateExpression> { public StringVectorRotateExpression() { } [StorableConstructor] protected StringVectorRotateExpression(bool deserializing) : base(deserializing) { } public override bool IsNoop(IInternalPushInterpreter interpreter) { return interpreter.StringVectorStack.Count < 3; } public override void Eval(IInternalPushInterpreter interpreter) { Eval(interpreter.StringVectorStack); } } }