namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions { using System; using System.Collections.Generic; using HeuristicLab.Common; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool; using Interpreter; [Serializable] [StorableClass] public abstract class Expression : IDeepCloneable, IPooledObject { protected Expression() { } [StorableConstructor] protected Expression(bool deserializing) { } public bool IsProgram { get { return GetType() == typeof(PushProgram); } } public static readonly IReadOnlyCollection EmptyContainer = new Expression[0]; public abstract string StringRepresentation { get; } public abstract bool IsNoop(IInternalPushInterpreter interpreter); public abstract void Eval(IInternalPushInterpreter interpreter); public bool TryEval(IInternalPushInterpreter interpreter) { if (IsNoop(interpreter)) return false; Eval(interpreter); return true; } public override string ToString() { return StringRepresentation; } public object Clone() { return Clone(new Cloner()); } public virtual IDeepCloneable Clone(Cloner cloner) { return this; } void IPooledObject.Init() { } void IPooledObject.Reset() { } } }