Changeset 10011 for branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/LogicalExpression.cs
- Timestamp:
- 10/01/13 12:08:25 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Robocode.TrunkInt/HeuristicLab.Problems.Robocode/3.3/Symbols/Logical Expressions/LogicalExpression.cs
r9790 r10011 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 37 38 38 39 [StorableConstructor] 39 private LogicalExpression(bool deserializing) : base(deserializing) { } 40 private LogicalExpression(LogicalExpression original, Cloner cloner) 41 : base(original, cloner) { 42 } 40 protected LogicalExpression(bool deserializing) : base(deserializing) { } 41 protected LogicalExpression(LogicalExpression original, Cloner cloner) : base(original, cloner) { } 43 42 44 public LogicalExpression() 45 : base("LogicalExpression", "A LogicalExpression.") { 46 this.Prefix = ""; 47 this.Suffix = ""; 48 } 43 public LogicalExpression() : base("LogicalExpression", "A logical expression.") { } 49 44 50 45 public override IDeepCloneable Clone(Cloner cloner) { … … 52 47 } 53 48 54 public override string Interpret(ISymbolicExpressionTreeNode node, System.Collections.Generic.IEnumerable<ISymbolicExpressionTreeNode> children) {49 public override string Interpret(ISymbolicExpressionTreeNode node, IEnumerable<ISymbolicExpressionTreeNode> children) { 55 50 var enumerator = children.GetEnumerator(); 51 if (!enumerator.MoveNext()) throw new System.Exception("LogicalExpression was not given a child."); 56 52 57 if (!enumerator.MoveNext()) throw new System.Exception("LogicalExpression was not given a child.");58 53 var symbol = enumerator.Current.Symbol; 59 60 if (!(symbol is LogicalValue || symbol is LogicalComparison || 61 symbol is NumericalComparison || symbol is Negation)) 62 throw new System.Exception("LogicalExpression was given a child of type " + symbol.GetType().ToString() + 63 ". The expected child must be of type " + typeof(LogicalValue).ToString() + " or " + 64 typeof(LogicalComparison).ToString() + " or " + typeof(NumericalComparison).ToString() + " or " + 65 typeof(Negation).ToString() + "."); 54 if (!(symbol is LogicalValue || symbol is Conjunction || symbol is Disjunction || symbol is Negation)) 55 throw new System.Exception("LogicalExpression was given a child of type " + symbol.GetType() + 56 ". The expected child must be of type " + typeof(LogicalValue) 57 + " or " + typeof(Conjunction) 58 + " or " + typeof(Disjunction) 59 + " or " + typeof(Negation) + "."); 66 60 67 61 string result = ((CodeNode)symbol).Interpret(enumerator.Current, enumerator.Current.Subtrees); 68 62 if (enumerator.MoveNext()) throw new System.Exception("LogicalExpression was given more than one child."); 69 63 70 return this.Prefix + result + this.Suffix;64 return result; 71 65 } 72 66 }
Note: See TracChangeset
for help on using the changeset viewer.