1 | using System.Collections.Generic;
|
---|
2 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; |
---|
3 | |
---|
4 | namespace HeuristicLab.Problems.ProgramSynthesis {
|
---|
5 | [StorableClass]
|
---|
6 | public abstract class PopExpression<T> : StatelessExpression {
|
---|
7 | protected PopExpression() { }
|
---|
8 | [StorableConstructor]
|
---|
9 | protected PopExpression(bool deserializing) : base(deserializing) { }
|
---|
10 |
|
---|
11 | protected void Eval(IPushStack<T> stack) {
|
---|
12 | stack.Pop();
|
---|
13 | }
|
---|
14 | }
|
---|
15 |
|
---|
16 | [StorableClass]
|
---|
17 | [PushExpression(StackTypes.Integer, "INTEGER.POP", "Pops the top INTEGER item.")]
|
---|
18 | public class IntegerPopExpression : PopExpression<long> {
|
---|
19 | public IntegerPopExpression() { }
|
---|
20 | [StorableConstructor]
|
---|
21 | protected IntegerPopExpression(bool deserializing) : base(deserializing) { }
|
---|
22 |
|
---|
23 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
24 | return interpreter.IntegerStack.IsEmpty;
|
---|
25 | }
|
---|
26 |
|
---|
27 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
28 | Eval(interpreter.IntegerStack);
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 | [StorableClass]
|
---|
33 | [PushExpression(StackTypes.Float, "FLOAT.POP", "Pops the top FLOAT item.")]
|
---|
34 | public class FloatPopExpression : PopExpression<double> {
|
---|
35 | public FloatPopExpression() { }
|
---|
36 | [StorableConstructor]
|
---|
37 | protected FloatPopExpression(bool deserializing) : base(deserializing) { }
|
---|
38 |
|
---|
39 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
40 | return interpreter.FloatStack.IsEmpty;
|
---|
41 | }
|
---|
42 |
|
---|
43 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
44 | Eval(interpreter.FloatStack);
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
48 | [StorableClass]
|
---|
49 | [PushExpression(StackTypes.Boolean, "BOOLEAN.POP", "Pops the top BOOLEAN item.")]
|
---|
50 | public class BooleanPopExpression : PopExpression<bool> {
|
---|
51 | public BooleanPopExpression() { }
|
---|
52 | [StorableConstructor]
|
---|
53 | protected BooleanPopExpression(bool deserializing) : base(deserializing) { }
|
---|
54 |
|
---|
55 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
56 | return interpreter.BooleanStack.IsEmpty;
|
---|
57 | }
|
---|
58 |
|
---|
59 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
60 | Eval(interpreter.BooleanStack);
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | [StorableClass]
|
---|
65 | [PushExpression(StackTypes.Name, "NAME.POP", "Pops the top NAME item.")]
|
---|
66 | public class NamePopExpression : PopExpression<string> {
|
---|
67 | public NamePopExpression() { }
|
---|
68 | [StorableConstructor]
|
---|
69 | protected NamePopExpression(bool deserializing) : base(deserializing) { }
|
---|
70 |
|
---|
71 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
72 | return interpreter.NameStack.IsEmpty;
|
---|
73 | }
|
---|
74 |
|
---|
75 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
76 | Eval(interpreter.NameStack);
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | [StorableClass]
|
---|
81 | [PushExpression(StackTypes.Exec, "EXEC.POP", "Pops the top EXEC item.", requiredBlockCount: 1)]
|
---|
82 | public class ExecPopExpression : PopExpression<Expression> {
|
---|
83 | public ExecPopExpression() { }
|
---|
84 | [StorableConstructor]
|
---|
85 | protected ExecPopExpression(bool deserializing) : base(deserializing) { }
|
---|
86 |
|
---|
87 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
88 | return interpreter.ExecStack.IsEmpty;
|
---|
89 | }
|
---|
90 |
|
---|
91 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
92 | Eval(interpreter.ExecStack);
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | [StorableClass]
|
---|
97 | [PushExpression(StackTypes.Code, "CODE.POP", "Pops the top CODE item.")]
|
---|
98 | public class CodePopExpression : PopExpression<Expression> {
|
---|
99 | public CodePopExpression() { }
|
---|
100 | [StorableConstructor]
|
---|
101 | protected CodePopExpression(bool deserializing) : base(deserializing) { }
|
---|
102 |
|
---|
103 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
104 | return interpreter.CodeStack.IsEmpty;
|
---|
105 | }
|
---|
106 |
|
---|
107 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
108 | Eval(interpreter.CodeStack);
|
---|
109 | }
|
---|
110 | }
|
---|
111 |
|
---|
112 | [StorableClass]
|
---|
113 | [PushExpression(StackTypes.Char, "CHAR.POP", "Pops the top CHAR item.")]
|
---|
114 | public class CharPopExpression : PopExpression<char> {
|
---|
115 | public CharPopExpression() { }
|
---|
116 | [StorableConstructor]
|
---|
117 | protected CharPopExpression(bool deserializing) : base(deserializing) { }
|
---|
118 |
|
---|
119 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
120 | return interpreter.CharStack.IsEmpty;
|
---|
121 | }
|
---|
122 |
|
---|
123 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
124 | Eval(interpreter.CharStack);
|
---|
125 | }
|
---|
126 | }
|
---|
127 |
|
---|
128 | [StorableClass]
|
---|
129 | [PushExpression(StackTypes.String, "STRING.POP", "Pops the top STRING item.")]
|
---|
130 | public class StringPopExpression : PopExpression<string> {
|
---|
131 | public StringPopExpression() { }
|
---|
132 | [StorableConstructor]
|
---|
133 | protected StringPopExpression(bool deserializing) : base(deserializing) { }
|
---|
134 |
|
---|
135 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
136 | return interpreter.StringStack.IsEmpty;
|
---|
137 | }
|
---|
138 |
|
---|
139 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
140 | Eval(interpreter.StringStack);
|
---|
141 | }
|
---|
142 | }
|
---|
143 |
|
---|
144 | [StorableClass]
|
---|
145 | [PushExpression(StackTypes.IntegerVector, "INTEGER[].POP", "Pops the top INTEGER[] item.")]
|
---|
146 | public class IntegerVectorPopExpression : PopExpression<IReadOnlyList<long>> {
|
---|
147 | public IntegerVectorPopExpression() { }
|
---|
148 | [StorableConstructor]
|
---|
149 | protected IntegerVectorPopExpression(bool deserializing) : base(deserializing) { }
|
---|
150 |
|
---|
151 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
152 | return interpreter.IntegerVectorStack.IsEmpty;
|
---|
153 | }
|
---|
154 |
|
---|
155 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
156 | Eval(interpreter.IntegerVectorStack);
|
---|
157 | }
|
---|
158 | }
|
---|
159 |
|
---|
160 | [StorableClass]
|
---|
161 | [PushExpression(StackTypes.FloatVector, "FLOAT[].POP", "Pops the top FLOAT[] item.")]
|
---|
162 | public class FloatVectorPopExpression : PopExpression<IReadOnlyList<double>> {
|
---|
163 | public FloatVectorPopExpression() { }
|
---|
164 | [StorableConstructor]
|
---|
165 | protected FloatVectorPopExpression(bool deserializing) : base(deserializing) { }
|
---|
166 |
|
---|
167 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
168 | return interpreter.FloatVectorStack.IsEmpty;
|
---|
169 | }
|
---|
170 |
|
---|
171 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
172 | Eval(interpreter.FloatVectorStack);
|
---|
173 | }
|
---|
174 | }
|
---|
175 |
|
---|
176 | [StorableClass]
|
---|
177 | [PushExpression(StackTypes.BooleanVector, "BOOLEAN[].POP", "Pops the top BOOLEAN[] item.")]
|
---|
178 | public class BooleanVectorPopExpression : PopExpression<IReadOnlyList<bool>> {
|
---|
179 | public BooleanVectorPopExpression() { }
|
---|
180 | [StorableConstructor]
|
---|
181 | protected BooleanVectorPopExpression(bool deserializing) : base(deserializing) { }
|
---|
182 |
|
---|
183 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
184 | return interpreter.BooleanVectorStack.IsEmpty;
|
---|
185 | }
|
---|
186 |
|
---|
187 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
188 | Eval(interpreter.BooleanVectorStack);
|
---|
189 | }
|
---|
190 | }
|
---|
191 |
|
---|
192 | [StorableClass]
|
---|
193 | [PushExpression(StackTypes.StringVector, "STRING[].POP", "Pops the top STRING[] item.")]
|
---|
194 | public class StringVectorPopExpression : PopExpression<IReadOnlyList<string>> {
|
---|
195 | public StringVectorPopExpression() { }
|
---|
196 | [StorableConstructor]
|
---|
197 | protected StringVectorPopExpression(bool deserializing) : base(deserializing) { }
|
---|
198 |
|
---|
199 | public override bool IsNoop(IInternalPushInterpreter interpreter) {
|
---|
200 | return interpreter.StringVectorStack.IsEmpty;
|
---|
201 | }
|
---|
202 |
|
---|
203 | public override void Eval(IInternalPushInterpreter interpreter) {
|
---|
204 | Eval(interpreter.StringVectorStack);
|
---|
205 | }
|
---|
206 | }
|
---|
207 | } |
---|