[15771] | 1 | using System.Collections.Generic;
|
---|
| 2 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; |
---|
| 3 | |
---|
| 4 | namespace HeuristicLab.Problems.ProgramSynthesis { |
---|
[14727] | 5 | /// <summary>
|
---|
[15032] | 6 | /// Empties the given stack.
|
---|
[14727] | 7 | /// </summary>
|
---|
| 8 | /// <typeparam name="T">Stacktype</typeparam>
|
---|
[14952] | 9 | [StorableClass]
|
---|
[14727] | 10 | public abstract class FlushExpression<T> : StatelessExpression {
|
---|
[14952] | 11 | protected FlushExpression() { }
|
---|
| 12 | [StorableConstructor]
|
---|
| 13 | protected FlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 14 |
|
---|
| 15 | protected void Eval(IPushStack<T> stack) {
|
---|
[14727] | 16 | stack.Clear();
|
---|
| 17 | }
|
---|
| 18 | }
|
---|
| 19 |
|
---|
[15032] | 20 | [PushExpression(
|
---|
| 21 | StackTypes.Integer,
|
---|
| 22 | "INTEGER.FLUSH",
|
---|
| 23 | "Empties the INTEGER stack.")]
|
---|
[14952] | 24 | [StorableClass]
|
---|
[14727] | 25 | public class IntegerFlushExpression : FlushExpression<long> {
|
---|
[14952] | 26 | public IntegerFlushExpression() { }
|
---|
| 27 | [StorableConstructor]
|
---|
| 28 | protected IntegerFlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 29 |
|
---|
| 30 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
| 31 | return interpreter.IntegerStack.IsEmpty;
|
---|
[14727] | 32 | }
|
---|
[14952] | 33 |
|
---|
| 34 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
| 35 | Eval(interpreter.IntegerStack);
|
---|
| 36 | }
|
---|
[14727] | 37 | }
|
---|
| 38 |
|
---|
[15032] | 39 | [PushExpression(
|
---|
| 40 | StackTypes.Float,
|
---|
| 41 | "FLOAT.FLUSH",
|
---|
| 42 | "Empties the FLOAT stack.")]
|
---|
[14952] | 43 | [StorableClass]
|
---|
[14727] | 44 | public class FloatFlushExpression : FlushExpression<double> {
|
---|
[14952] | 45 | public FloatFlushExpression() { }
|
---|
| 46 | [StorableConstructor]
|
---|
| 47 | protected FloatFlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 48 |
|
---|
| 49 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
| 50 | return interpreter.FloatStack.IsEmpty;
|
---|
[14727] | 51 | }
|
---|
[14952] | 52 |
|
---|
| 53 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
| 54 | Eval(interpreter.FloatStack);
|
---|
| 55 | }
|
---|
[14727] | 56 | }
|
---|
| 57 |
|
---|
[15032] | 58 | [PushExpression(
|
---|
| 59 | StackTypes.Boolean,
|
---|
| 60 | "BOOLEAN.FLUSH",
|
---|
| 61 | "Empties the BOOLEAN stack.")]
|
---|
[14952] | 62 | [StorableClass]
|
---|
[14727] | 63 | public class BooleanFlushExpression : FlushExpression<bool> {
|
---|
[14952] | 64 | public BooleanFlushExpression() { }
|
---|
| 65 | [StorableConstructor]
|
---|
| 66 | protected BooleanFlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 67 |
|
---|
| 68 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
| 69 | return interpreter.BooleanStack.IsEmpty;
|
---|
[14727] | 70 | }
|
---|
[14952] | 71 |
|
---|
| 72 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
| 73 | Eval(interpreter.BooleanStack);
|
---|
| 74 | }
|
---|
[14727] | 75 | }
|
---|
| 76 |
|
---|
[15032] | 77 | [PushExpression(
|
---|
| 78 | StackTypes.Name,
|
---|
| 79 | "NAME.FLUSH",
|
---|
| 80 | "Empties the NAME stack.")]
|
---|
[14952] | 81 | [StorableClass]
|
---|
[14727] | 82 | public class NameFlushExpression : FlushExpression<string> {
|
---|
[14952] | 83 | public NameFlushExpression() { }
|
---|
| 84 | [StorableConstructor]
|
---|
| 85 | protected NameFlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 86 |
|
---|
| 87 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
| 88 | return interpreter.NameStack.IsEmpty;
|
---|
[14727] | 89 | }
|
---|
[14952] | 90 |
|
---|
| 91 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
| 92 | Eval(interpreter.NameStack);
|
---|
| 93 | }
|
---|
[14727] | 94 | }
|
---|
| 95 |
|
---|
[15032] | 96 | [PushExpression(
|
---|
| 97 | StackTypes.Exec,
|
---|
| 98 | "EXEC.FLUSH",
|
---|
| 99 | "Empties the EXEC stack.")]
|
---|
[14952] | 100 | [StorableClass]
|
---|
[14727] | 101 | public class ExecFlushExpression : FlushExpression<Expression> {
|
---|
[14952] | 102 | public ExecFlushExpression() { }
|
---|
| 103 | [StorableConstructor]
|
---|
| 104 | protected ExecFlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 105 |
|
---|
| 106 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
| 107 | return interpreter.ExecStack.IsEmpty;
|
---|
[14727] | 108 | }
|
---|
[14952] | 109 |
|
---|
| 110 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
| 111 | Eval(interpreter.ExecStack);
|
---|
| 112 | }
|
---|
[14727] | 113 | }
|
---|
| 114 |
|
---|
[15032] | 115 | [PushExpression(
|
---|
| 116 | StackTypes.Code,
|
---|
| 117 | "CODE.FLUSH",
|
---|
| 118 | "Empties the CODE stack.")]
|
---|
[14952] | 119 | [StorableClass]
|
---|
[14727] | 120 | public class CodeFlushExpression : FlushExpression<Expression> {
|
---|
[14952] | 121 | public CodeFlushExpression() { }
|
---|
| 122 | [StorableConstructor]
|
---|
| 123 | protected CodeFlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 124 |
|
---|
| 125 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
| 126 | return interpreter.CodeStack.IsEmpty;
|
---|
[14727] | 127 | }
|
---|
[14952] | 128 |
|
---|
| 129 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
| 130 | Eval(interpreter.CodeStack);
|
---|
| 131 | }
|
---|
[14727] | 132 | }
|
---|
[14777] | 133 |
|
---|
[15032] | 134 | [PushExpression(
|
---|
| 135 | StackTypes.Char,
|
---|
| 136 | "CHAR.FLUSH",
|
---|
| 137 | "Empties the CHAR stack.")]
|
---|
[14952] | 138 | [StorableClass]
|
---|
[14777] | 139 | public class CharFlushExpression : FlushExpression<char> {
|
---|
[14952] | 140 | public CharFlushExpression() { }
|
---|
| 141 | [StorableConstructor]
|
---|
| 142 | protected CharFlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 143 |
|
---|
| 144 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
| 145 | return interpreter.CharStack.IsEmpty;
|
---|
[14777] | 146 | }
|
---|
[14952] | 147 |
|
---|
| 148 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
| 149 | Eval(interpreter.CharStack);
|
---|
| 150 | }
|
---|
[14777] | 151 | }
|
---|
| 152 |
|
---|
[15032] | 153 | [PushExpression(
|
---|
| 154 | StackTypes.String,
|
---|
| 155 | "STRING.FLUSH",
|
---|
| 156 | "Empties the STRING stack.")]
|
---|
[14952] | 157 | [StorableClass]
|
---|
[14777] | 158 | public class StringFlushExpression : FlushExpression<string> {
|
---|
[14952] | 159 | public StringFlushExpression() { }
|
---|
| 160 | [StorableConstructor]
|
---|
| 161 | protected StringFlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 162 |
|
---|
| 163 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
| 164 | return interpreter.StringStack.IsEmpty;
|
---|
[14777] | 165 | }
|
---|
[14952] | 166 |
|
---|
| 167 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
| 168 | Eval(interpreter.StringStack);
|
---|
| 169 | }
|
---|
[14777] | 170 | }
|
---|
[14834] | 171 |
|
---|
[15032] | 172 | [PushExpression(
|
---|
| 173 | StackTypes.IntegerVector,
|
---|
| 174 | "INTEGER[].FLUSH",
|
---|
| 175 | "Empties the INTEGER[] stack.")]
|
---|
[14952] | 176 | [StorableClass]
|
---|
[15017] | 177 | public class IntegerVectorFlushExpression : FlushExpression<IReadOnlyList<long>> {
|
---|
[14952] | 178 | public IntegerVectorFlushExpression() { }
|
---|
| 179 | [StorableConstructor]
|
---|
| 180 | protected IntegerVectorFlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 181 |
|
---|
| 182 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
| 183 | return interpreter.IntegerVectorStack.IsEmpty;
|
---|
[14834] | 184 | }
|
---|
[14952] | 185 |
|
---|
| 186 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
| 187 | Eval(interpreter.IntegerVectorStack);
|
---|
| 188 | }
|
---|
[14834] | 189 | }
|
---|
[14875] | 190 |
|
---|
[15032] | 191 | [PushExpression(
|
---|
| 192 | StackTypes.FloatVector,
|
---|
| 193 | "FLOAT[].FLUSH",
|
---|
| 194 | "Empties the FLOAT[] stack.")]
|
---|
[14952] | 195 | [StorableClass]
|
---|
[15017] | 196 | public class FloatVectorFlushExpression : FlushExpression<IReadOnlyList<double>> {
|
---|
[14952] | 197 | public FloatVectorFlushExpression() { }
|
---|
| 198 | [StorableConstructor]
|
---|
| 199 | protected FloatVectorFlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 200 |
|
---|
| 201 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
| 202 | return interpreter.FloatVectorStack.IsEmpty;
|
---|
[14875] | 203 | }
|
---|
[14952] | 204 |
|
---|
| 205 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
| 206 | Eval(interpreter.FloatVectorStack);
|
---|
| 207 | }
|
---|
[14875] | 208 | }
|
---|
| 209 |
|
---|
[15032] | 210 | [PushExpression(
|
---|
| 211 | StackTypes.BooleanVector,
|
---|
| 212 | "BOOLEAN[].FLUSH",
|
---|
| 213 | "Empties the BOOLEAN[] stack.")]
|
---|
[14952] | 214 | [StorableClass]
|
---|
[15017] | 215 | public class BooleanVectorFlushExpression : FlushExpression<IReadOnlyList<bool>> {
|
---|
[14952] | 216 | public BooleanVectorFlushExpression() { }
|
---|
| 217 | [StorableConstructor]
|
---|
| 218 | protected BooleanVectorFlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 219 |
|
---|
| 220 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
| 221 | return interpreter.BooleanVectorStack.IsEmpty;
|
---|
[14875] | 222 | }
|
---|
[14952] | 223 |
|
---|
| 224 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
| 225 | Eval(interpreter.BooleanVectorStack);
|
---|
| 226 | }
|
---|
[14875] | 227 | }
|
---|
| 228 |
|
---|
[15032] | 229 | [PushExpression(
|
---|
| 230 | StackTypes.StringVector,
|
---|
| 231 | "STRING[].FLUSH",
|
---|
| 232 | "Empties the STRING[] stack.")]
|
---|
[14952] | 233 | [StorableClass]
|
---|
[15017] | 234 | public class StringVectorFlushExpression : FlushExpression<IReadOnlyList<string>> {
|
---|
[14952] | 235 | public StringVectorFlushExpression() { }
|
---|
| 236 | [StorableConstructor]
|
---|
| 237 | protected StringVectorFlushExpression(bool deserializing) : base(deserializing) { }
|
---|
| 238 |
|
---|
| 239 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
| 240 | return interpreter.StringVectorStack.IsEmpty;
|
---|
[14875] | 241 | }
|
---|
[14952] | 242 |
|
---|
| 243 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
| 244 | Eval(interpreter.StringVectorStack);
|
---|
| 245 | }
|
---|
[14875] | 246 | }
|
---|
[14727] | 247 | } |
---|