Changeset 14952 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Interpreter/PushInterpreter.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/Interpreter/PushInterpreter.cs
r14914 r14952 192 192 193 193 /* Push top expression so the loop is able to enter 194 * If the top expression is a single statement then the loop has nothing to do. 195 * Otherwise the expand expression will be evaluated and pushes code onto the EXEC stack. 196 * Expanding the initial program is not counted */ 197 ExecStack.Push(expression); 198 199 if (Configuration.TopLevelPushCode) CodeStack.Push(expression); 200 201 // expand if program 202 if (expression.IsProgram) 203 DoStep(); 194 * If the top expression is a single statement it gets evaluated in Run. 195 * Otherwise the push program will be evaluated and the expressions of the program are pushed onto the EXEC stack. 196 * Expanding the initial program is not counted in ExecCount */ 197 InitRun(expression); 198 199 if (Configuration.TopLevelPushCode && CodeStack.IsEnabled) 200 CodeStack.Push(expression); 204 201 205 202 Run(); … … 309 306 [MethodImpl(MethodImplOptions.AggressiveInlining)] 310 307 private void Finally() { 311 if (Configuration.TopLevelPopCode && !CodeStack.IsEmpty )308 if (Configuration.TopLevelPopCode && !CodeStack.IsEmpty && CodeStack.IsEnabled) 312 309 CodeStack.Pop(); 313 310 314 311 PoolContainer.DisposePools(); 312 } 313 314 private void InitRun(Expression expression) { 315 ExecStack.Push(expression); 316 317 if (!expression.IsProgram) 318 return; 319 320 DoStep(); 321 ExecCounter--; // unpacking the initial program is not counted 315 322 } 316 323 … … 324 331 325 332 var expression = ExecStack.Pop(); 326 var succ = expression. Eval(this);333 var succ = expression.TryEval(this); 327 334 328 335 if ((ExecStack.Count > 0 && ExecStack.Top == null) || … … 341 348 private bool DoStep() { 342 349 ExecCounter++; 343 return ExecStack.Pop(). Eval(this);350 return ExecStack.Pop().TryEval(this); 344 351 } 345 352 #endif … … 347 354 [MethodImpl(MethodImplOptions.AggressiveInlining)] 348 355 private void DoTenSteps() { 349 ExecStack[0]. Eval(this);350 ExecStack[1]. Eval(this);351 ExecStack[2]. Eval(this);352 ExecStack[3]. Eval(this);353 ExecStack[4]. Eval(this);354 ExecStack[5]. Eval(this);355 ExecStack[6]. Eval(this);356 ExecStack[7]. Eval(this);357 ExecStack[8]. Eval(this);358 ExecStack[9]. Eval(this);356 ExecStack[0].TryEval(this); 357 ExecStack[1].TryEval(this); 358 ExecStack[2].TryEval(this); 359 ExecStack[3].TryEval(this); 360 ExecStack[4].TryEval(this); 361 ExecStack[5].TryEval(this); 362 ExecStack[6].TryEval(this); 363 ExecStack[7].TryEval(this); 364 ExecStack[8].TryEval(this); 365 ExecStack[9].TryEval(this); 359 366 360 367 ExecStack.Remove(10);
Note: See TracChangeset
for help on using the changeset viewer.