Changeset 14952 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorPushAllExpressions.cs
- Timestamp:
- 05/10/17 11:23:05 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorPushAllExpressions.cs
r14834 r14952 2 2 using System.Collections.Generic; 3 3 4 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 4 5 using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes; 5 6 using HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter; … … 10 11 /// </summary> 11 12 /// <typeparam name="T"></typeparam> 13 [StorableClass] 12 14 public abstract class VectorPushAllExpression<T> : StatelessExpression { 13 protected bool Eval(IPushStack<List<T>> vectorStack, IPushStack<T> literalStack) {14 if (vectorStack.IsEmpty)15 return false;15 protected VectorPushAllExpression() { } 16 [StorableConstructor] 17 protected VectorPushAllExpression(bool deserializing) : base(deserializing) { } 16 18 19 protected bool IsNoop(IPushStack<List<T>> vectorStack) { 20 return vectorStack.IsEmpty; 21 } 22 23 protected void Eval(IPushStack<List<T>> vectorStack, IPushStack<T> literalStack) { 17 24 var vector = vectorStack.Pop(); 18 25 vector.Reverse(); 19 26 literalStack.Push(vector); 20 return true;21 27 } 22 28 } 23 29 30 [StorableClass] 24 31 [PushExpression(StackTypes.IntegerVector, "INTEGER[].PUSHALL", StackTypes.Integer)] 25 32 public class IntegerVectorPushAllExpression : VectorPushAllExpression<long> { 26 public override bool Eval(IInternalPushInterpreter interpreter) { 27 return Eval(interpreter.IntegerVectorStack, interpreter.IntegerStack); 33 public IntegerVectorPushAllExpression() { } 34 [StorableConstructor] 35 protected IntegerVectorPushAllExpression(bool deserializing) : base(deserializing) { } 36 37 public override bool IsNoop(IInternalPushInterpreter interpreter) { 38 return IsNoop(interpreter.IntegerVectorStack); 39 } 40 41 public override void Eval(IInternalPushInterpreter interpreter) { 42 Eval(interpreter.IntegerVectorStack, interpreter.IntegerStack); 28 43 } 29 44 } 30 45 46 [StorableClass] 31 47 [PushExpression(StackTypes.FloatVector, "FLOAT[].PUSHALL", StackTypes.Float)] 32 48 public class FloatVectorPushAllExpression : VectorPushAllExpression<double> { 33 public override bool Eval(IInternalPushInterpreter interpreter) { 34 return Eval(interpreter.FloatVectorStack, interpreter.FloatStack); 49 public FloatVectorPushAllExpression() { } 50 [StorableConstructor] 51 protected FloatVectorPushAllExpression(bool deserializing) : base(deserializing) { } 52 53 public override bool IsNoop(IInternalPushInterpreter interpreter) { 54 return IsNoop(interpreter.FloatVectorStack); 55 } 56 57 public override void Eval(IInternalPushInterpreter interpreter) { 58 Eval(interpreter.FloatVectorStack, interpreter.FloatStack); 35 59 } 36 60 } 37 61 62 [StorableClass] 38 63 [PushExpression(StackTypes.BooleanVector, "BOOLEAN[].PUSHALL", StackTypes.Boolean)] 39 64 public class BooleanVectorPushAllExpression : VectorPushAllExpression<bool> { 40 public override bool Eval(IInternalPushInterpreter interpreter) { 41 return Eval(interpreter.BooleanVectorStack, interpreter.BooleanStack); 65 public BooleanVectorPushAllExpression() { } 66 [StorableConstructor] 67 protected BooleanVectorPushAllExpression(bool deserializing) : base(deserializing) { } 68 69 public override bool IsNoop(IInternalPushInterpreter interpreter) { 70 return IsNoop(interpreter.BooleanVectorStack); 71 } 72 73 public override void Eval(IInternalPushInterpreter interpreter) { 74 Eval(interpreter.BooleanVectorStack, interpreter.BooleanStack); 42 75 } 43 76 } 44 77 78 [StorableClass] 45 79 [PushExpression(StackTypes.StringVector, "STRING[].PUSHALL", StackTypes.String)] 46 80 public class StringVectorPushAllExpression : VectorPushAllExpression<string> { 47 public override bool Eval(IInternalPushInterpreter interpreter) { 48 return Eval(interpreter.StringVectorStack, interpreter.StringStack); 81 public StringVectorPushAllExpression() { } 82 [StorableConstructor] 83 protected StringVectorPushAllExpression(bool deserializing) : base(deserializing) { } 84 85 public override bool IsNoop(IInternalPushInterpreter interpreter) { 86 return IsNoop(interpreter.StringVectorStack); 87 } 88 89 public override void Eval(IInternalPushInterpreter interpreter) { 90 Eval(interpreter.StringVectorStack, interpreter.StringStack); 49 91 } 50 92 }
Note: See TracChangeset
for help on using the changeset viewer.