Changeset 15032 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/ExecExpressions.cs
- Timestamp:
- 06/12/17 14:11:43 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/ExecExpressions.cs
r15017 r15032 15 15 /// </summary> 16 16 [StorableClass] 17 [PushExpression(StackTypes.Exec, "EXEC.IF", StackTypes.Boolean, execIn: 2)] 17 [PushExpression( 18 StackTypes.Exec, 19 "EXEC.IF", 20 "If the top item of the BOOLEAN stack is TRUE then this removes the second item on the EXEC stack, leaving the first item to be executed. If it is false then it removes the first item, leaving the second to be executed.", 21 StackTypes.Boolean, 22 execIn: 2)] 18 23 public class ExecIfExpression : StatelessExpression { 19 24 public ExecIfExpression() { } … … 34 39 35 40 /// <summary> 36 /// Inserts beneath the top item of the EXEC stack a new item of the form 37 /// "( EXEC.Y <TopItem> )". 38 /// </summary> 39 [PushExpression(StackTypes.Exec, "EXEC.Y", execIn: 1)] 41 /// Inserts beneath the top item of the EXEC stack a new item of the form "( EXEC.Y <TopItem> )". 42 /// </summary> 43 [PushExpression( 44 StackTypes.Exec, 45 "EXEC.Y", 46 "Inserts beneath the top item of the EXEC stack a new item of the form \"( EXEC.Y <TopItem> )\"", 47 execIn: 1)] 40 48 [StorableClass] 41 49 public class ExecYExpression : StatelessExpression { … … 66 74 67 75 /// <summary> 68 /// Removes the second item on the EXEC stack. 69 /// </summary> 70 [PushExpression(StackTypes.Exec, "EXEC.K", execIn: 2)] 76 /// Removes the second item on the EXEC stack. 77 /// </summary> 78 [PushExpression( 79 StackTypes.Exec, 80 "EXEC.K", 81 "Removes the second item on the EXEC stack.", 82 execIn: 2)] 71 83 [StorableClass] 72 84 public class ExecKExpression : StatelessExpression { … … 86 98 87 99 /// <summary> 88 /// Pops 3 items from the EXEC stack, which we will call A, B, and C 89 /// (with A being the first one popped). Then pushes a list containing B and C back onto the EXEC stack, followed by 90 /// another instance of C, followed by another instance of A. 91 /// </summary> 92 [PushExpression(StackTypes.Exec, "EXEC.S", execIn: 3)] 100 /// Pops 3 items from the EXEC stack, which we will call A, B, and C 101 /// (with A being the first one popped). Then pushes a list containing B and C back onto the EXEC stack, followed by 102 /// another instance of C, followed by another instance of A. 103 /// </summary> 104 [PushExpression( 105 StackTypes.Exec, 106 "EXEC.S", 107 "Pops 3 items from the EXEC stack called A, B, and C. Then pushes a list containing B and C back onto the EXEC stack, followed by another instance of C, followed by another instance of A.", 108 execIn: 3)] 93 109 [StorableClass] 94 110 public class ExecSExpression : StatelessExpression { … … 121 137 122 138 /// <summary> 123 /// 139 /// Does nothing. 124 140 /// </summary> 125 141 /// 126 142 [StorableClass] 127 143 [Serializable] 128 [PushExpression(StackTypes.Exec, "EXEC.NOOP")] 144 [PushExpression( 145 StackTypes.Exec, 146 "EXEC.NOOP", 147 "Does nothing.")] 129 148 public class ExecNoopExpression : StatelessExpression { 130 149 public ExecNoopExpression() { } … … 141 160 } 142 161 143 [PushExpression(StackTypes.Exec, "EXEC.WHILE", StackTypes.Boolean, execIn: 1)] 162 /// <summary> 163 /// Executes top EXEC item recursively as long top BOOLEAN is TRUE. 164 /// </summary> 165 [PushExpression( 166 StackTypes.Exec, 167 "EXEC.WHILE", 168 "Executes top EXEC item recursively as long top BOOLEAN is TRUE.", 169 StackTypes.Boolean, execIn: 1)] 144 170 [StorableClass] 145 171 public class ExecWhileExpression : StatelessExpression { … … 153 179 154 180 public override void Eval(IInternalPushInterpreter interpreter) { 155 if (interpreter.BooleanStack.IsEmpty) { 181 if (interpreter.BooleanStack.IsEmpty || 182 !interpreter.BooleanStack.Pop()) { 156 183 interpreter.ExecStack.Pop(); 157 184 return; 158 185 } 159 186 160 var booleanTop = interpreter.BooleanStack.Pop();161 162 if (!booleanTop) {163 interpreter.ExecStack.Pop();164 return;165 }166 167 187 interpreter.ExecStack.Push(this, interpreter.ExecStack.Top); 168 188 } 169 189 } 170 190 171 [PushExpression(StackTypes.Exec, "EXEC.DO*WHILE", execIn: 1)] 191 /// <summary> 192 /// Executes top EXEC item recursively until max. amount of eval. expressions is reached or top EXEC item removes the the recursive call. 193 /// </summary> 194 [PushExpression( 195 StackTypes.Exec, 196 "EXEC.DO*WHILE", 197 "Executes top EXEC item recursively until max. amount of eval. expressions is reached or top EXEC item removes the the recursive call.", 198 execIn: 1)] 172 199 [StorableClass] 173 200 public class ExecDoWhileExpression : StatelessExpression { … … 185 212 } 186 213 187 [PushExpression(StackTypes.Exec, "EXEC.WHEN", StackTypes.Boolean, execIn: 1)] 214 /// <summary> 215 /// Top EXEC item is only executed, if top BOOLEAN is TRUE. 216 /// </summary> 217 [PushExpression( 218 StackTypes.Exec, 219 "EXEC.WHEN", 220 "Top EXEC item is only executed, if top BOOLEAN is TRUE.", 221 StackTypes.Boolean, 222 execIn: 1)] 188 223 [StorableClass] 189 224 public class ExecWhenExpression : StatelessExpression {
Note: See TracChangeset
for help on using the changeset viewer.