using System; using HeuristicLab.Common; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Problems.ProgramSynthesis { [Serializable] [StorableClass] public abstract class Expression : IDeepCloneable, IPooledObject { protected Expression() { } [StorableConstructor] protected Expression(bool deserializing) { } protected Expression(Expression origin, Cloner cloner) { } public bool IsProgram { get { return GetType() == typeof(PushProgram); } } 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 this; } public virtual IDeepCloneable Clone(Cloner cloner) { return this; } void IPooledObject.Reset() { } } }