Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/EmptyExpression.cs @ 16958

Last change on this file since 16958 was 15344, checked in by pkimmesw, 7 years ago

#2665 Fixed Integer Overflow Exceptions, Adjusted Offspring Selection Experiments

File size: 7.4 KB
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions {
2
3  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
4  using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes;
5  using HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter;
6
7  using Stack;
8
9  /// <summary>
10  /// Tells whether that stack is empty.
11  /// </summary>
12  [StorableClass]
13  public abstract class EmptyExpression : StatelessExpression {
14    protected EmptyExpression() { }
15    [StorableConstructor]
16    protected EmptyExpression(bool deserializing) : base(deserializing) { }
17
18    public override bool IsNoop(IInternalPushInterpreter interpreter) {
19      return false;
20    }
21
22    public void Eval(IPushStack stack, IPushStack<bool> booleanStack) {
23      booleanStack.Push(stack.IsEmpty);
24    }
25  }
26
27  [StorableClass]
28  [PushExpression(
29    StackTypes.Exec,
30    "EXEC.EMPTY",
31    "Pushes TRUE onto the BOOLEAN stack if the EXEC stack is empty, otherwise FALSE.",
32    StackTypes.Boolean)]
33  public class ExecEmptyExpression : EmptyExpression {
34    public ExecEmptyExpression() { }
35    [StorableConstructor]
36    protected ExecEmptyExpression(bool deserializing) : base(deserializing) { }
37
38    public override void Eval(IInternalPushInterpreter interpreter) {
39      Eval(interpreter.ExecStack, interpreter.BooleanStack);
40    }
41  }
42
43  [StorableClass]
44  [PushExpression(
45    StackTypes.Code,
46    "CODE.EMPTY",
47    "Pushes TRUE onto the BOOLEAN stack if the CODE stack is empty, otherwise FALSE.",
48    StackTypes.Boolean)]
49  public class CodeEmptyExpression : EmptyExpression {
50    public CodeEmptyExpression() { }
51    [StorableConstructor]
52    protected CodeEmptyExpression(bool deserializing) : base(deserializing) { }
53    public override void Eval(IInternalPushInterpreter interpreter) {
54      Eval(interpreter.CodeStack, interpreter.BooleanStack);
55    }
56  }
57
58  [StorableClass]
59  [PushExpression(
60    StackTypes.Integer,
61    "INTEGER.EMPTY",
62    "Pushes TRUE onto the BOOLEAN stack if the INTEGER stack is empty, otherwise FALSE.",
63    StackTypes.Boolean)]
64  public class IntegerEmptyExpression : EmptyExpression {
65    public IntegerEmptyExpression() { }
66    [StorableConstructor]
67    protected IntegerEmptyExpression(bool deserializing) : base(deserializing) { }
68    public override void Eval(IInternalPushInterpreter interpreter) {
69      Eval(interpreter.IntegerStack, interpreter.BooleanStack);
70    }
71  }
72
73  [StorableClass]
74  [PushExpression(
75    StackTypes.Float,
76    "FLOAT.EMPTY", "Pushes TRUE onto the BOOLEAN stack if the FLOAT stack is empty, otherwise FALSE.",
77    StackTypes.Boolean)]
78  public class FloatEmptyExpression : EmptyExpression {
79    public FloatEmptyExpression() { }
80    [StorableConstructor]
81    protected FloatEmptyExpression(bool deserializing) : base(deserializing) { }
82    public override void Eval(IInternalPushInterpreter interpreter) {
83      Eval(interpreter.FloatStack, interpreter.BooleanStack);
84    }
85  }
86
87  [StorableClass]
88  [PushExpression(
89    StackTypes.Boolean,
90    "BOOLEAN.EMPTY",
91    "Pushes TRUE onto the BOOLEAN stack if the BOOLEAN stack is empty, otherwise FALSE.")]
92  public class BooleanEmptyExpression : EmptyExpression {
93    public BooleanEmptyExpression() { }
94    [StorableConstructor]
95    protected BooleanEmptyExpression(bool deserializing) : base(deserializing) { }
96    public override void Eval(IInternalPushInterpreter interpreter) {
97      Eval(interpreter.BooleanStack, interpreter.BooleanStack);
98    }
99  }
100
101  [StorableClass]
102  [PushExpression(
103    StackTypes.Char,
104    "CHAR.EMPTY",
105    "Pushes TRUE onto the BOOLEAN stack if the CHAR stack is empty, otherwise FALSE.",
106    StackTypes.Boolean)]
107  public class CharEmptyExpression : EmptyExpression {
108    public CharEmptyExpression() { }
109    [StorableConstructor]
110    protected CharEmptyExpression(bool deserializing) : base(deserializing) { }
111    public override void Eval(IInternalPushInterpreter interpreter) {
112      Eval(interpreter.CharStack, interpreter.BooleanStack);
113    }
114  }
115
116  [StorableClass]
117  [PushExpression(
118    StackTypes.String,
119    "STRING.EMPTY",
120    "Pushes TRUE onto the BOOLEAN stack if the STRING stack is empty, otherwise FALSE.",
121    StackTypes.Boolean)]
122  public class StringEmptyExpression : EmptyExpression {
123    public StringEmptyExpression() { }
124    [StorableConstructor]
125    protected StringEmptyExpression(bool deserializing) : base(deserializing) { }
126    public override void Eval(IInternalPushInterpreter interpreter) {
127      Eval(interpreter.StringStack, interpreter.BooleanStack);
128    }
129  }
130
131  [StorableClass]
132  [PushExpression(
133    StackTypes.IntegerVector,
134    "INTEGER[].EMPTY",
135    "Pushes TRUE onto the BOOLEAN stack if the INTEGER[] stack is empty, otherwise FALSE.",
136    StackTypes.Boolean)]
137  public class IntegerVectorEmptyExpression : EmptyExpression {
138    public IntegerVectorEmptyExpression() { }
139    [StorableConstructor]
140    protected IntegerVectorEmptyExpression(bool deserializing) : base(deserializing) { }
141    public override void Eval(IInternalPushInterpreter interpreter) {
142      Eval(interpreter.IntegerVectorStack, interpreter.BooleanStack);
143    }
144  }
145
146  [StorableClass]
147  [PushExpression(
148    StackTypes.FloatVector,
149    "FLOAT[].EMPTY",
150    "Pushes TRUE onto the BOOLEAN stack if the FLOAT[] stack is empty, otherwise FALSE.",
151    StackTypes.Boolean)]
152  public class FloatVectorEmptyExpression : EmptyExpression {
153    public FloatVectorEmptyExpression() { }
154    [StorableConstructor]
155    protected FloatVectorEmptyExpression(bool deserializing) : base(deserializing) { }
156    public override void Eval(IInternalPushInterpreter interpreter) {
157      Eval(interpreter.FloatVectorStack, interpreter.BooleanStack);
158    }
159  }
160
161  [StorableClass]
162  [PushExpression(
163    StackTypes.BooleanVector,
164    "BOOLEAN[].EMPTY",
165    "Pushes TRUE onto the BOOLEAN stack if the BOOLEAN[] stack is empty, otherwise FALSE.",
166    StackTypes.Boolean)]
167  public class BooleanVectorEmptyExpression : EmptyExpression {
168    public BooleanVectorEmptyExpression() { }
169    [StorableConstructor]
170    protected BooleanVectorEmptyExpression(bool deserializing) : base(deserializing) { }
171    public override void Eval(IInternalPushInterpreter interpreter) {
172      Eval(interpreter.BooleanVectorStack, interpreter.BooleanStack);
173    }
174  }
175
176  [StorableClass]
177  [PushExpression(
178    StackTypes.StringVector,
179    "STRING[].EMPTY",
180    "Pushes TRUE onto the BOOLEAN stack if the STRING[] stack is empty, otherwise FALSE.",
181    StackTypes.Boolean)]
182  public class StringVectorEmptyExpression : EmptyExpression {
183    public StringVectorEmptyExpression() { }
184    [StorableConstructor]
185    protected StringVectorEmptyExpression(bool deserializing) : base(deserializing) { }
186    public override void Eval(IInternalPushInterpreter interpreter) {
187      Eval(interpreter.StringVectorStack, interpreter.BooleanStack);
188    }
189  }
190
191  [StorableClass]
192  [PushExpression(
193  StackTypes.Print,
194  "PRINT.EMPTY",
195  "Pushes TRUE onto the BOOLEAN stack if the PRINT stack is empty, otherwise FALSE.",
196  StackTypes.Boolean)]
197  public class PrintEmptyExpression : EmptyExpression {
198    public PrintEmptyExpression() { }
199    [StorableConstructor]
200    protected PrintEmptyExpression(bool deserializing) : base(deserializing) { }
201    public override void Eval(IInternalPushInterpreter interpreter) {
202      Eval(interpreter.PrintStack, interpreter.BooleanStack);
203    }
204  }
205}
Note: See TracBrowser for help on using the repository browser.