Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/FlushExpressions.cs @ 14875

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

#2665 BenchmarkSuite, all examples, partially tested, VectorExpressions added

File size: 3.5 KB
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions {
2  using System.Collections.Generic;
3
4  using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes;
5
6  using Interpreter;
7  using Stack;
8
9  /// <summary>
10  ///     Empties the given stack.
11  /// </summary>
12  /// <typeparam name="T">Stacktype</typeparam>
13  public abstract class FlushExpression<T> : StatelessExpression {
14    public bool Eval(IPushStack<T> stack) {
15      stack.Clear();
16      return true;
17    }
18  }
19
20  [PushExpression(StackTypes.Integer, "INTEGER.FLUSH")]
21  public class IntegerFlushExpression : FlushExpression<long> {
22    public override bool Eval(IInternalPushInterpreter interpreter) {
23      return Eval(interpreter.IntegerStack);
24    }
25  }
26
27  [PushExpression(StackTypes.Float, "FLOAT.FLUSH")]
28  public class FloatFlushExpression : FlushExpression<double> {
29    public override bool Eval(IInternalPushInterpreter interpreter) {
30      return Eval(interpreter.FloatStack);
31    }
32  }
33
34  [PushExpression(StackTypes.Boolean, "BOOLEAN.FLUSH")]
35  public class BooleanFlushExpression : FlushExpression<bool> {
36    public override bool Eval(IInternalPushInterpreter interpreter) {
37      return Eval(interpreter.BooleanStack);
38    }
39  }
40
41  [PushExpression(StackTypes.Name, "NAME.FLUSH")]
42  public class NameFlushExpression : FlushExpression<string> {
43    public override bool Eval(IInternalPushInterpreter interpreter) {
44      return Eval(interpreter.NameStack);
45    }
46  }
47
48  [PushExpression(StackTypes.Exec, "EXEC.FLUSH")]
49  public class ExecFlushExpression : FlushExpression<Expression> {
50    public override bool Eval(IInternalPushInterpreter interpreter) {
51      return Eval(interpreter.ExecStack);
52    }
53  }
54
55  [PushExpression(StackTypes.Code, "CODE.FLUSH")]
56  public class CodeFlushExpression : FlushExpression<Expression> {
57    public override bool Eval(IInternalPushInterpreter interpreter) {
58      return Eval(interpreter.CodeStack);
59    }
60  }
61
62  [PushExpression(StackTypes.Char, "CHAR.FLUSH")]
63  public class CharFlushExpression : FlushExpression<char> {
64    public override bool Eval(IInternalPushInterpreter interpreter) {
65      return Eval(interpreter.CharStack);
66    }
67  }
68
69  [PushExpression(StackTypes.String, "STRING.FLUSH")]
70  public class StringFlushExpression : FlushExpression<string> {
71    public override bool Eval(IInternalPushInterpreter interpreter) {
72      return Eval(interpreter.StringStack);
73    }
74  }
75
76  [PushExpression(StackTypes.IntegerVector, "INTEGER[].FLUSH")]
77  public class IntegerVectorFlushExpression : FlushExpression<List<long>> {
78    public override bool Eval(IInternalPushInterpreter interpreter) {
79      return Eval(interpreter.IntegerVectorStack);
80    }
81  }
82
83  [PushExpression(StackTypes.FloatVector, "FLOAT[].FLUSH")]
84  public class FloatVectorFlushExpression : FlushExpression<List<double>> {
85    public override bool Eval(IInternalPushInterpreter interpreter) {
86      return Eval(interpreter.FloatVectorStack);
87    }
88  }
89
90  [PushExpression(StackTypes.BooleanVector, "BOOLEAN[].FLUSH")]
91  public class BooleanVectorFlushExpression : FlushExpression<List<bool>> {
92    public override bool Eval(IInternalPushInterpreter interpreter) {
93      return Eval(interpreter.BooleanVectorStack);
94    }
95  }
96
97  [PushExpression(StackTypes.StringVector, "STRING[].FLUSH")]
98  public class StringVectorFlushExpression : FlushExpression<List<string>> {
99    public override bool Eval(IInternalPushInterpreter interpreter) {
100      return Eval(interpreter.StringVectorStack);
101    }
102  }
103}
Note: See TracBrowser for help on using the repository browser.