Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/PushExpressions.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.Interpreter;
3  using HeuristicLab.Problems.ProgramSynthesis.Push.Stack;
4
5  public abstract class PushExpression<T> : StatefulExpression<T> {
6
7    protected PushExpression(T state) : base(state) { }
8
9    protected bool Eval(IStack<T> stack) {
10      stack.Push(this.State);
11      return true;
12    }
13
14    public override string StringRepresentation { get { return this.State.ToString(); } }
15  }
16
17  public class IntegerPushExpression : PushExpression<long> {
18    public IntegerPushExpression(long state)
19      : base(state) {
20    }
21
22    public override bool Eval(IPushInterpreter interpreter) {
23      return Eval(interpreter.IntegerStack);
24    }
25  }
26
27  public class FloatPushExpression : PushExpression<double> {
28    public FloatPushExpression(double state)
29      : base(state) {
30    }
31
32    public override bool Eval(IPushInterpreter interpreter) {
33      return Eval(interpreter.FloatStack);
34    }
35  }
36
37  public class BooleanPushExpression : PushExpression<bool> {
38    public BooleanPushExpression(bool state)
39      : base(state) {
40    }
41
42    public override bool Eval(IPushInterpreter interpreter) {
43      return Eval(interpreter.BooleanStack);
44    }
45  }
46
47  public class NamePushExpression : PushExpression<string> {
48    public NamePushExpression(string state)
49      : base(state) {
50    }
51
52    public override bool Eval(IPushInterpreter interpreter) {
53      return Eval(interpreter.NameStack);
54    }
55  }
56
57  public class ExecPushExpression : PushExpression<Expression> {
58    public ExecPushExpression(Expression state)
59      : base(state) {
60    }
61
62    public override bool Eval(IPushInterpreter interpreter) {
63      return Eval(interpreter.ExecStack);
64    }
65  }
66
67  public class CharPushExpression : PushExpression<char> {
68    public CharPushExpression(char state)
69      : base(state) {
70    }
71
72    public override bool Eval(IPushInterpreter interpreter) {
73      return Eval(interpreter.CharStack);
74    }
75  }
76
77  public class StringPushExpression : PushExpression<string> {
78    public StringPushExpression(string state)
79      : base(state) {
80    }
81
82    public override bool Eval(IPushInterpreter interpreter) {
83      return Eval(interpreter.StringStack);
84    }
85  }
86}
Note: See TracBrowser for help on using the repository browser.