Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/Expression.cs @ 14746

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

#2665 PooledPushProgram reduces memory usage and increases performance

File size: 942 bytes
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions {
2  using System;
3  using System.Collections.Generic;
4
5  using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes;
6
7  using Interpreter;
8
9  [Serializable]
10  public abstract class Expression {
11    public bool IsProgram { get { return this.GetType() == typeof(PushProgram); } }
12
13    public static readonly IReadOnlyCollection<Expression> EmptyContainer = new Expression[0];
14
15    public virtual string StringRepresentation
16    {
17      get
18      {
19        var attribute = (PushExpressionAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(PushExpressionAttribute));
20
21        return attribute != null
22          ? attribute.ExpressionName
23          : string.Empty;
24      }
25    }
26
27    public abstract bool Eval(IPushInterpreter interpreter);
28
29    public override string ToString() {
30      return this.StringRepresentation;
31    }
32  }
33}
Note: See TracBrowser for help on using the repository browser.