Changeset 4904 for branches/HeuristicLab.DebugEngine/DebugEngine.cs
- Timestamp:
- 11/22/10 17:06:12 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DebugEngine/DebugEngine.cs
r4903 r4904 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using System.Threading; … … 48 49 Log = cloner.Clone(original.Log); 49 50 ExecutionStack = cloner.Clone(original.ExecutionStack); 51 OperatorTrace = new ItemList<IOperator>(original.OperatorTrace.Select(op => cloner.Clone(op))); 52 operatorParents = original.operatorParents.ToDictionary(kvp => cloner.Clone(kvp.Key), kvp => cloner.Clone(kvp.Value)); 50 53 pausePending = original.pausePending; 51 54 stopPending = original.stopPending; … … 60 63 Log = new Log(); 61 64 ExecutionStack = new ExecutionStack(); 65 OperatorTrace = new ItemList<IOperator>(); 66 operatorParents = new Dictionary<IAtomicOperation, IAtomicOperation>(); 62 67 pausePending = stopPending = false; 63 68 timer = new System.Timers.Timer(100); … … 110 115 } 111 116 117 [Storable] 118 public ItemList<IOperator> OperatorTrace { get; private set; } 119 120 [Storable] 121 private Dictionary<IAtomicOperation, IAtomicOperation> operatorParents; 122 112 123 #endregion 113 124 … … 131 142 ignoreNextBreakpoint = false; 132 143 CurrentOperation = null; 144 OperatorTrace.Clear(); 145 operatorParents.Clear(); 133 146 OnPrepared(); 134 147 } … … 140 153 ignoreNextBreakpoint = false; 141 154 CurrentOperation = null; 155 OperatorTrace.Clear(); 156 operatorParents.Clear(); 142 157 OnPrepared(); 143 158 } … … 161 176 public override void Start() { 162 177 base.Start(); 163 CurrentOperation = null;164 178 ThreadPool.QueueUserWorkItem(new WaitCallback(Run), null); 165 179 } … … 250 264 ExpandOperationCollection(operations); 251 265 } else if (ExecutionStack.Count > 0) { 252 Log.LogMessage("Pop ing execution stack");266 Log.LogMessage("Popping execution stack"); 253 267 CurrentOperation = ExecutionStack.Last(); 254 268 ExecutionStack.RemoveAt(ExecutionStack.Count - 1); … … 256 270 Log.LogMessage("Nothing to do"); 257 271 } 272 GenerateOperationTrace(); 258 273 } catch (Exception x) { 259 274 OnExceptionOccurred(x); 275 } 276 } 277 278 private void GenerateOperationTrace() { 279 var operation = CurrentOperation as IAtomicOperation; 280 if (operation != null) { 281 List<IOperator> trace = new List<IOperator>(); 282 while (operation != null) { 283 trace.Add(operation.Operator); 284 IAtomicOperation parent = null; 285 operatorParents.TryGetValue(operation, out parent); 286 operation = parent; 287 } 288 trace.Reverse(); 289 OperatorTrace.Clear(); 290 OperatorTrace.AddRange(trace); 260 291 } 261 292 } … … 276 307 currentOperator = operation.Operator; 277 308 IOperation successor = operation.Operator.Execute((IExecutionContext)operation); 278 CurrentOperation = null;279 currentOperator = null;280 309 if (successor != null) { 310 AssignParents(operation, successor); 281 311 ExecutionStack.Add(successor); 282 312 } 313 currentOperator = null; 314 CurrentOperation = null; 283 315 } catch (Exception ex) { 284 316 OnExceptionOccurred(new OperatorExecutionException(operation.Operator, ex)); … … 288 320 } 289 321 322 private void AssignParents(IAtomicOperation parent, IOperation successor) { 323 OperationCollection operations = successor as OperationCollection; 324 if (operations != null) 325 foreach (var op in operations) 326 AssignParents(parent, op); 327 IAtomicOperation atomicOperation = successor as IAtomicOperation; 328 if (atomicOperation != null && atomicOperation.Operator != null && !operatorParents.ContainsKey(atomicOperation)) 329 operatorParents[atomicOperation] = parent; 330 } 331 290 332 protected virtual void ExpandOperationCollection(OperationCollection operations) { 291 333 ExecutionStack.AddRange(operations.Reverse());
Note: See TracChangeset
for help on using the changeset viewer.