- Timestamp:
- 04/09/10 17:28:32 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.ArtificialAnt/3.3/AntInterpreter.cs
r3239 r3294 21 21 22 22 using System; 23 using System.Linq; 23 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 24 25 using HeuristicLab.Data; 25 26 using System.Collections.Generic; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.GeneralSymbols; 26 28 27 29 namespace HeuristicLab.Problems.ArtificialAnt { … … 80 82 // expression evaluated completly => start at root again 81 83 if (nodeStack.Count == 0) 82 nodeStack.Push(Expression.R oot.SubTrees[0]);84 nodeStack.Push(Expression.ResultProducingExpression); 83 85 var currentNode = nodeStack.Pop(); 84 86 if (currentNode.Symbol is Left) { … … 112 114 nodeStack.Push(currentNode.SubTrees[0]); 113 115 return; 116 } else if (currentNode.Symbol is InvokeFunction) { 117 var invokeNode = currentNode as InvokeFunctionTreeNode; 118 var funBranch = (from node in expression.Root.SubTrees 119 let funNode = node as DefunTreeNode 120 where funNode != null 121 where funNode.Name == invokeNode.InvokedFunctionName 122 select funNode).FirstOrDefault(); 123 if (funBranch == null) throw new InvalidOperationException("Can't find definition of function " + invokeNode.InvokedFunctionName); 124 nodeStack.Push(funBranch.SubTrees[0]); 125 foreach (var subTree in invokeNode.SubTrees) 126 nodeStack.Push(subTree); 127 } else if(currentNode.Symbol is Argument) { 128 // do nothing 114 129 } else { 115 130 throw new InvalidOperationException(currentNode.Symbol.ToString());
Note: See TracChangeset
for help on using the changeset viewer.