Ignore:
Timestamp:
04/10/17 00:27:31 (3 years ago)
Author:
pkimmesw
Message:

#2665 LexicaseSelector, Performance improvements, UI Fixes, Debugger only shows used stacks, fixed Debugger stepping, Added vector expressions, ERCOptions,

File:
1 edited

Legend:

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

    r14777 r14834  
    99  using System.Collections.Generic;
    1010  using System.Linq;
    11 
    12   using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes;
    13   using HeuristicLab.Problems.ProgramSynthesis.Push.Stack;
    14 
     11  using Attributes;
    1512  using Interpreter;
     13  using Stack;
    1614
    1715  /// <summary>
     
    2220  [PushExpression(StackTypes.Code, "CODE.DO", StackTypes.Exec)]
    2321  public class CodeDoExpression : StatelessExpression {
    24     public override bool Eval(IPushInterpreter interpreter) {
     22    public override bool Eval(IInternalPushInterpreter interpreter) {
    2523      // not enough arguments on stack
    2624      if (interpreter.CodeStack.Count == 0) return false;
     
    3836  [PushExpression(StackTypes.Code, "CODE.DO*", StackTypes.Exec)]
    3937  public class CodeDoXExpression : StatelessExpression {
    40     public override bool Eval(IPushInterpreter interpreter) {
     38    public override bool Eval(IInternalPushInterpreter interpreter) {
    4139      // not enough arguments on stack
    4240      if (interpreter.CodeStack.Count == 0) return false;
     
    5452  [PushExpression(StackTypes.Code, "CODE.NOOP")]
    5553  public class CodeNoopExpression : StatelessExpression {
    56     public override bool Eval(IPushInterpreter interpreter) {
     54    public override bool Eval(IInternalPushInterpreter interpreter) {
    5755      return false;
    5856    }
     
    6563  [PushExpression(StackTypes.Code, "CODE.QUOTE", StackTypes.Exec)]
    6664  public class CodeQuoteExpression : StatelessExpression {
    67     public override bool Eval(IPushInterpreter interpreter) {
     65    public override bool Eval(IInternalPushInterpreter interpreter) {
    6866      // not enough arguments on stack
    6967      if (interpreter.ExecStack.Count == 0) return false;
     
    8381  [PushExpression(StackTypes.Code, "CODE.IF", StackTypes.Exec | StackTypes.Boolean)]
    8482  public class CodeIfExpression : StatelessExpression {
    85     public override bool Eval(IPushInterpreter interpreter) {
     83    public override bool Eval(IInternalPushInterpreter interpreter) {
    8684      // not enough arguments on stack
    8785      if ((interpreter.BooleanStack.Count == 0) || (interpreter.CodeStack.Count < 2)) return false;
     
    102100  [PushExpression(StackTypes.Code, "CODE.APPEND")]
    103101  public class CodeAppendExpression : StatelessExpression {
    104     public override bool Eval(IPushInterpreter interpreter) {
     102    public override bool Eval(IInternalPushInterpreter interpreter) {
    105103      if (interpreter.CodeStack.Count < 2) return false;
    106104
     
    164162  [PushExpression(StackTypes.Code, "CODE.ATOM", StackTypes.Boolean)]
    165163  public class CodeAtomExpression : StatelessExpression {
    166     public override bool Eval(IPushInterpreter interpreter) {
     164    public override bool Eval(IInternalPushInterpreter interpreter) {
    167165      if (interpreter.CodeStack.Count == 0) return false;
    168166
     
    183181  [PushExpression(StackTypes.Code, "CODE.CAR")]
    184182  public class CodeCarExpression : StatelessExpression {
    185     public override bool Eval(IPushInterpreter interpreter) {
     183    public override bool Eval(IInternalPushInterpreter interpreter) {
    186184      if (interpreter.CodeStack.Count == 0 ||
    187           interpreter.CodeStack.Top.IsProgram) return false;
     185          !interpreter.CodeStack.Top.IsProgram) return false;
    188186
    189187      var expand = interpreter.CodeStack.Top as PushProgram;
     
    205203  [PushExpression(StackTypes.Code, "CODE.CDR")]
    206204  public class CodeCdrExpression : StatelessExpression {
    207     public override bool Eval(IPushInterpreter interpreter) {
     205    public override bool Eval(IInternalPushInterpreter interpreter) {
    208206      if (interpreter.CodeStack.Count == 0) return false;
    209207
     
    236234  [PushExpression(StackTypes.Code, "CODE.CONS")]
    237235  public class CodeConsExpression : StatelessExpression {
    238     public override bool Eval(IPushInterpreter interpreter) {
     236    public override bool Eval(IInternalPushInterpreter interpreter) {
    239237      if (interpreter.CodeStack.Count < 2 ||
    240238         (interpreter.CodeStack.Top.IsProgram &&
     
    242240        return false;
    243241
    244       PushProgram result;
    245 
    246242      var expressions = interpreter.PoolContainer.ExpressionListPool.Get();
    247243      var first = interpreter.CodeStack.Pop();
     
    254250
    255251      expressions.Add(interpreter.CodeStack.Top);
    256       result = PushProgram.Create(interpreter.PoolContainer.PushProgramPool, expressions);
     252      var result = PushProgram.Create(interpreter.PoolContainer.PushProgramPool, expressions);
    257253      interpreter.CodeStack.SetTop(result);
    258254
     
    271267  [PushExpression(StackTypes.Code, "CODE.CONTAINER")]
    272268  public class CodeContainerExpression : StatelessExpression {
    273     public override bool Eval(IPushInterpreter interpreter) {
     269    public override bool Eval(IInternalPushInterpreter interpreter) {
    274270      if ((interpreter.CodeStack.Count < 2) ||
    275271          (interpreter.CodeStack[interpreter.CodeStack.Count - 2].GetType() !=
     
    310306  [PushExpression(StackTypes.Code, "CODE.CONTAINS", StackTypes.Boolean)]
    311307  public class CodeContainsExpression : StatelessExpression {
    312     public override bool Eval(IPushInterpreter interpreter) {
     308    public override bool Eval(IInternalPushInterpreter interpreter) {
    313309      if (interpreter.CodeStack.Count < 2 ||
    314310         !interpreter.CodeStack[interpreter.CodeStack.Count - 2].IsProgram)
     
    332328  [PushExpression(StackTypes.Code, "CODE.DEFINITION", StackTypes.Name)]
    333329  public class CodeDefinitionExpression : StatelessExpression {
    334     public override bool Eval(IPushInterpreter interpreter) {
     330    public override bool Eval(IInternalPushInterpreter interpreter) {
    335331      if ((interpreter.NameStack.Count == 0) ||
    336332          !interpreter.CustomExpressions.ContainsKey(interpreter.NameStack.Top)) return false;
     
    372368  [PushExpression(StackTypes.Code, "CODE.DISCREPANCY", StackTypes.Integer)]
    373369  public class CodeDiscrepancyExpression : StatelessExpression {
    374     public override bool Eval(IPushInterpreter interpreter) {
     370    public override bool Eval(IInternalPushInterpreter interpreter) {
    375371      if (interpreter.CodeStack.Count < 2) return false;
    376372
     
    430426  [PushExpression(StackTypes.Code, "CODE.EXTRACT", StackTypes.Integer)]
    431427  public class CodeExtractExpression : StatelessExpression {
    432     public override bool Eval(IPushInterpreter interpreter) {
     428    public override bool Eval(IInternalPushInterpreter interpreter) {
    433429      if (interpreter.IntegerStack.Count == 0 ||
    434430          interpreter.CodeStack.Count == 0 ||
     
    451447  [PushExpression(StackTypes.Code, "CODE.FROMBOOLEAN", StackTypes.Boolean)]
    452448  public class CodeFromBooleanExpression : StatelessExpression {
    453     public override bool Eval(IPushInterpreter interpreter) {
     449    public override bool Eval(IInternalPushInterpreter interpreter) {
    454450      if (interpreter.BooleanStack.Count == 0) return false;
    455451
     
    468464  [PushExpression(StackTypes.Code, "CODE.FROMFLOAT", StackTypes.Float)]
    469465  public class CodeFromFloatExpression : StatelessExpression {
    470     public override bool Eval(IPushInterpreter interpreter) {
     466    public override bool Eval(IInternalPushInterpreter interpreter) {
    471467      if (interpreter.FloatStack.Count == 0) return false;
    472468
     
    485481  [PushExpression(StackTypes.Code, "CODE.FROMINTEGER", StackTypes.Integer)]
    486482  public class CodeFromIntegerExpression : StatelessExpression {
    487     public override bool Eval(IPushInterpreter interpreter) {
     483    public override bool Eval(IInternalPushInterpreter interpreter) {
    488484      if (interpreter.IntegerStack.Count == 0) return false;
    489485
     
    502498  [PushExpression(StackTypes.Code, "CODE.FROMNAME", StackTypes.Name)]
    503499  public class CodeFromNameExpression : StatelessExpression {
    504     public override bool Eval(IPushInterpreter interpreter) {
     500    public override bool Eval(IInternalPushInterpreter interpreter) {
    505501      if (interpreter.NameStack.Count == 0) return false;
    506502
     
    520516  [PushExpression(StackTypes.Code, "CODE.CODEINSERT", StackTypes.Integer)]
    521517  public class CodeInsertExpression : StatelessExpression {
    522     public override bool Eval(IPushInterpreter interpreter) {
     518    public override bool Eval(IInternalPushInterpreter interpreter) {
    523519      if (interpreter.IntegerStack.Count == 0 ||
    524520          interpreter.CodeStack.Count < 2 ||
     
    558554  [PushExpression(StackTypes.Code, "CODE.LENGTH", StackTypes.Integer)]
    559555  public class CodeLengthExpression : StatelessExpression {
    560     public override bool Eval(IPushInterpreter interpreter) {
     556    public override bool Eval(IInternalPushInterpreter interpreter) {
    561557      if (interpreter.CodeStack.Count == 0) return false;
    562558
     
    578574  [PushExpression(StackTypes.Code, "CODE.LIST")]
    579575  public class CodeListExpression : StatelessExpression {
    580     public override bool Eval(IPushInterpreter interpreter) {
     576    public override bool Eval(IInternalPushInterpreter interpreter) {
    581577      if (interpreter.CodeStack.Count < 2 ||
    582578         (interpreter.CodeStack.Top.IsProgram && ((PushProgram)interpreter.CodeStack.Top).Depth == interpreter.Configuration.MaxDepth) ||
     
    605601  [PushExpression(StackTypes.Code, "CODE.MEMBER", StackTypes.Boolean)]
    606602  public class CodeMemberExpression : StatelessExpression {
    607     public override bool Eval(IPushInterpreter interpreter) {
     603    public override bool Eval(IInternalPushInterpreter interpreter) {
    608604      if (interpreter.CodeStack.Count < 2) return false;
    609605
     
    627623  [PushExpression(StackTypes.Code, "CODE.NTH", StackTypes.Integer)]
    628624  public class CodeNthExpression : StatelessExpression {
    629     public override bool Eval(IPushInterpreter interpreter) {
     625    public override bool Eval(IInternalPushInterpreter interpreter) {
    630626      if ((interpreter.CodeStack.Count == 0) || (interpreter.IntegerStack.Count == 0)) return false;
    631627
     
    665661  [PushExpression(StackTypes.Code, "CODE.NTHCDR", StackTypes.Integer)]
    666662  public class CodeNthCdrExpression : StatelessExpression {
    667     public override bool Eval(IPushInterpreter interpreter) {
     663    public override bool Eval(IInternalPushInterpreter interpreter) {
    668664      if ((interpreter.CodeStack.Count == 0) || (interpreter.IntegerStack.Count == 0)) return false;
    669665
     
    698694  [PushExpression(StackTypes.Code, "CODE.NULL", StackTypes.Boolean)]
    699695  public class CodeNullExpression : StatelessExpression {
    700     public override bool Eval(IPushInterpreter interpreter) {
     696    public override bool Eval(IInternalPushInterpreter interpreter) {
    701697      if (interpreter.CodeStack.Count == 0) return false;
    702698
     
    715711  [PushExpression(StackTypes.Code, "CODE.POSITION", StackTypes.Integer)]
    716712  public class CodePositionExpression : StatelessExpression {
    717     public override bool Eval(IPushInterpreter interpreter) {
     713    public override bool Eval(IInternalPushInterpreter interpreter) {
    718714      if (interpreter.CodeStack.Count < 2) return false;
    719715
     
    742738  [PushExpression(StackTypes.Code, "CODE.SIZE", StackTypes.Integer)]
    743739  public class CodeSizeExpression : StatelessExpression {
    744     public override bool Eval(IPushInterpreter interpreter) {
     740    public override bool Eval(IInternalPushInterpreter interpreter) {
    745741      if (interpreter.CodeStack.Count == 0) return false;
    746742
     
    764760  [PushExpression(StackTypes.Code, "CODE.SUBST")]
    765761  public class CodeSubstitutionExpression : StatelessExpression {
    766     public override bool Eval(IPushInterpreter interpreter) {
     762    public override bool Eval(IInternalPushInterpreter interpreter) {
    767763      if ((interpreter.CodeStack.Count < 3) ||
    768764          (interpreter.CodeStack.Top.GetType() != typeof(PushProgram)))
Note: See TracChangeset for help on using the changeset viewer.