1 | namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions {
|
---|
2 | using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes;
|
---|
3 |
|
---|
4 | using Interpreter;
|
---|
5 | using Stack;
|
---|
6 |
|
---|
7 | public abstract class PopExpression<T> : StatelessExpression {
|
---|
8 | public void Eval(IStack<T> stack) {
|
---|
9 | if (stack.Count == 0) return;
|
---|
10 |
|
---|
11 | stack.Pop();
|
---|
12 | }
|
---|
13 | }
|
---|
14 |
|
---|
15 | [PushExpression(StackType.Integer, "INTEGER.POP")]
|
---|
16 | public class IntegerPopExpression : PopExpression<long> {
|
---|
17 | public override void Eval(IPushGpInterpreter interpreter) {
|
---|
18 | this.Eval(interpreter.IntegerStack);
|
---|
19 | }
|
---|
20 | }
|
---|
21 |
|
---|
22 | [PushExpression(StackType.Float, "FLOAT.POP")]
|
---|
23 | public class FloatPopExpression : PopExpression<double> {
|
---|
24 | public override void Eval(IPushGpInterpreter interpreter) {
|
---|
25 | this.Eval(interpreter.FloatStack);
|
---|
26 | }
|
---|
27 | }
|
---|
28 |
|
---|
29 | [PushExpression(StackType.Boolean, "BOOLEAN.POP")]
|
---|
30 | public class BooleanPopExpression : PopExpression<bool> {
|
---|
31 | public override void Eval(IPushGpInterpreter interpreter) {
|
---|
32 | this.Eval(interpreter.BooleanStack);
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | [PushExpression(StackType.Name, "NAME.POP")]
|
---|
37 | public class NamePopExpression : PopExpression<string> {
|
---|
38 | public override void Eval(IPushGpInterpreter interpreter) {
|
---|
39 | this.Eval(interpreter.NameStack);
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | [PushExpression(StackType.Exec, "EXEC.POP")]
|
---|
44 | public class ExecPopExpression : PopExpression<Expression> {
|
---|
45 | public override void Eval(IPushGpInterpreter interpreter) {
|
---|
46 | this.Eval(interpreter.ExecStack);
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | [PushExpression(StackType.Code, "CODE.POP")]
|
---|
51 | public class CodePopExpression : PopExpression<Expression> {
|
---|
52 | public override void Eval(IPushGpInterpreter interpreter) {
|
---|
53 | this.Eval(interpreter.CodeStack);
|
---|
54 | }
|
---|
55 | }
|
---|
56 | } |
---|