Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/10/17 11:23:05 (8 years ago)
Author:
pkimmesw
Message:

#2665 Added IsNoop to Expression, Made Expressions storable, Fixed Debugger, Fixed and improved problem data and result visualisation, Added custom ErcOption view, Added problem difficulty to problem data name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/DoRangeExpressions.cs

    r14908 r14952  
    33
    44  using Attributes;
     5
     6  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     7
    58  using Interpreter;
    69  using Stack;
    710
    811  [Serializable]
     12  [StorableClass]
    913  public abstract class DoRangeExpression : LoopExpression {
    1014    protected DoRangeExpression() { }
    1115    protected DoRangeExpression(LoopState state) : base(state) { }
     16    [StorableConstructor]
     17    protected DoRangeExpression(bool deserializing) : base(deserializing) { }
     18
    1219    protected override bool HasInsufficientArguments(IInternalPushInterpreter interpreter, IPushStack<Expression> sourceStack) {
    1320      return interpreter.IntegerStack.Count < 2 ||
     
    5158  /// </summary>
    5259  [Serializable]
     60  [StorableClass]
    5361  [PushExpression(StackTypes.Code, "CODE.DO*RANGE", StackTypes.Integer)]
    5462  public class CodeDoRangeExpression : DoRangeExpression {
    5563    public CodeDoRangeExpression() { }
     64    public CodeDoRangeExpression(LoopState state) : base(state) { }
     65    [StorableConstructor]
     66    protected CodeDoRangeExpression(bool deserializing) : base(deserializing) { }
    5667
    57     public CodeDoRangeExpression(LoopState state) : base(state) { }
    58     public override bool Eval(IInternalPushInterpreter interpreter) {
    59       return Eval(interpreter, interpreter.CodeStack);
     68    public override bool IsNoop(IInternalPushInterpreter interpreter) {
     69      return State.Body == null && HasInsufficientArguments(interpreter, interpreter.CodeStack);
     70    }
     71
     72    public override void Eval(IInternalPushInterpreter interpreter) {
     73      Eval(interpreter, interpreter.CodeStack);
    6074    }
    6175
     
    93107  /// </summary>
    94108  [Serializable]
     109  [StorableClass]
    95110  [PushExpression(StackTypes.Exec, "EXEC.DO*RANGE", StackTypes.Integer)]
    96111  public class ExecDoRangeExpression : DoRangeExpression {
     
    98113
    99114    public ExecDoRangeExpression(LoopState state) : base(state) { }
    100     public override bool Eval(IInternalPushInterpreter interpreter) {
    101       return Eval(interpreter, interpreter.ExecStack);
     115    [StorableConstructor]
     116    protected ExecDoRangeExpression(bool deserializing) : base(deserializing) { }
     117
     118    public override bool IsNoop(IInternalPushInterpreter interpreter) {
     119      return State.Body == null && HasInsufficientArguments(interpreter, interpreter.ExecStack);
     120    }
     121
     122    public override void Eval(IInternalPushInterpreter interpreter) {
     123      Eval(interpreter, interpreter.ExecStack);
    102124    }
    103125    protected override LoopExpression Clone(LoopState state, IInternalPushInterpreter interpreter) {
Note: See TracChangeset for help on using the changeset viewer.