Changeset 10046 for branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions
- Timestamp:
- 10/17/13 12:07:20 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Numerical Expressions/NumericalExpression.cs
r10011 r10046 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 24 using System.Linq; 23 25 using HeuristicLab.Common; 24 26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 48 50 49 51 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 50 var enumerator = children.GetEnumerator();51 if (!enumerator.MoveNext()) throw new System.Exception("NumericalExpression was not given a child.");52 if (children.Count() != 1) 53 throw new ArgumentException("Expected 1 child in NumericalExpression.", "children"); 52 54 53 var symbol = enumerator.Current.Symbol; 55 var exprTree = children.Single(); 56 var symbol = exprTree.Symbol; 54 57 if (!(symbol is Number || symbol is INumericalMethod || symbol is INumericalOperator)) 55 58 throw new System.Exception("NumericalExpression was given a child of type " + symbol.GetType() + … … 58 61 + " or " + typeof(INumericalOperator) + "."); 59 62 60 string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees); 61 if (enumerator.MoveNext()) throw new System.Exception("NumericalExpression was given more than one child."); 62 63 return result; 63 return Prefix + ((CodeNode)symbol).Interpret(exprTree, exprTree.Subtrees) + Suffix; 64 64 } 65 65 }
Note: See TracChangeset
for help on using the changeset viewer.