Free cookie consent management tool by TermsFeed Policy Generator

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

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

#2665 simplifier, push solution results view, performance improvements, small bug fixes, ui fixes

File size: 2.3 KB
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions {
2  using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes;
3
4  using Interpreter;
5  using Stack;
6
7  /// <summary>
8  ///     Empties the given stack.
9  /// </summary>
10  /// <typeparam name="T">Stacktype</typeparam>
11  public abstract class FlushExpression<T> : StatelessExpression {
12    public bool Eval(IStack<T> stack) {
13      stack.Clear();
14      return true;
15    }
16  }
17
18  [PushExpression(StackTypes.Integer, "INTEGER.FLUSH")]
19  public class IntegerFlushExpression : FlushExpression<long> {
20    public override bool Eval(IPushInterpreter interpreter) {
21      return Eval(interpreter.IntegerStack);
22    }
23  }
24
25  [PushExpression(StackTypes.Float, "FLOAT.FLUSH")]
26  public class FloatFlushExpression : FlushExpression<double> {
27    public override bool Eval(IPushInterpreter interpreter) {
28      return Eval(interpreter.FloatStack);
29    }
30  }
31
32  [PushExpression(StackTypes.Boolean, "BOOLEAN.FLUSH")]
33  public class BooleanFlushExpression : FlushExpression<bool> {
34    public override bool Eval(IPushInterpreter interpreter) {
35      return Eval(interpreter.BooleanStack);
36    }
37  }
38
39  [PushExpression(StackTypes.Name, "NAME.FLUSH")]
40  public class NameFlushExpression : FlushExpression<string> {
41    public override bool Eval(IPushInterpreter interpreter) {
42      return Eval(interpreter.NameStack);
43    }
44  }
45
46  [PushExpression(StackTypes.Exec, "EXEC.FLUSH")]
47  public class ExecFlushExpression : FlushExpression<Expression> {
48    public override bool Eval(IPushInterpreter interpreter) {
49      return Eval(interpreter.ExecStack);
50    }
51  }
52
53  [PushExpression(StackTypes.Code, "CODE.FLUSH")]
54  public class CodeFlushExpression : FlushExpression<Expression> {
55    public override bool Eval(IPushInterpreter interpreter) {
56      return Eval(interpreter.CodeStack);
57    }
58  }
59
60  [PushExpression(StackTypes.Char, "CHAR.FLUSH")]
61  public class CharFlushExpression : FlushExpression<char> {
62    public override bool Eval(IPushInterpreter interpreter) {
63      return Eval(interpreter.CharStack);
64    }
65  }
66
67  [PushExpression(StackTypes.String, "STRING.FLUSH")]
68  public class StringFlushExpression : FlushExpression<string> {
69    public override bool Eval(IPushInterpreter interpreter) {
70      return Eval(interpreter.StringStack);
71    }
72  }
73}
Note: See TracBrowser for help on using the repository browser.