Changeset 15189 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/PrintExpressions.cs
- Timestamp:
- 07/10/17 21:36:03 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/PrintExpressions.cs
r15032 r15189 2 2 using System.Collections.Generic; 3 3 using System.Globalization; 4 using System.Text;5 4 using Attributes; 6 5 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 7 6 using HeuristicLab.Problems.ProgramSynthesis.Push.Constants; 7 8 8 using Interpreter; 9 9 using Stack; … … 21 21 22 22 public override void Eval(IInternalPushInterpreter interpreter) { 23 interpreter.PrintStack. Push(string.Empty);23 interpreter.PrintStack.NewLine(); 24 24 } 25 25 } … … 28 28 public abstract class PrintExpression<T> : StatelessExpression { 29 29 protected PrintExpression() { } 30 30 31 [StorableConstructor] 31 32 protected PrintExpression(bool deserializing) : base(deserializing) { } 32 33 33 34 protected void Eval(IInternalPushInterpreter interpreter, IPushStack<T> stack) { 34 var value = stack.Pop().ToString(); 35 36 if (interpreter.PrintStack.IsEmpty) 37 interpreter.PrintStack.Push(value); 38 else 39 interpreter.PrintStack.Top += value; 35 var value = stack.Pop(); 36 37 interpreter.PrintStack.Push(value); 40 38 } 41 39 42 40 protected void EvalVector(IInternalPushInterpreter interpreter, IPushStack<IReadOnlyList<T>> vectorStack) { 43 var sb = new StringBuilder();44 41 var vector = vectorStack.Pop(); 45 42 46 sb.Append(PushEnvironment.VectorStartSymbol);43 interpreter.PrintStack.Push(PushEnvironment.VectorStartSymbol); 47 44 48 45 if (vector.Count > 0) { 49 sb.Append(vector[0]);46 interpreter.PrintStack.Push(vector[0]); 50 47 51 48 for (var i = 1; i < vector.Count; i++) { 52 sb.Append(PushEnvironment.VectorSeparatorSymbol);53 sb.Append(vector[i]);49 interpreter.PrintStack.Push(PushEnvironment.VectorSeparatorSymbol); 50 interpreter.PrintStack.Push(vector[i]); 54 51 } 55 52 } 56 53 57 sb.Append(PushEnvironment.VectorEndSymbol); 58 59 var value = sb.ToString(); 60 interpreter.PrintStack.Push(value); 54 interpreter.PrintStack.Push(PushEnvironment.VectorEndSymbol); 61 55 } 62 56 } … … 165 159 166 160 public override void Eval(IInternalPushInterpreter interpreter) { 167 Eval(interpreter, interpreter.IntegerStack); 161 var value = interpreter.IntegerStack.Pop(); 162 interpreter.PrintStack.Push(value); 168 163 } 169 164 }
Note: See TracChangeset
for help on using the changeset viewer.