- Timestamp:
- 04/19/10 10:18:15 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionEvaluator.cs
r3377 r3409 44 44 this.row = row; 45 45 pc = 0; 46 arguments.Clear(); 46 47 var estimatedValue = Evaluate(); 47 48 if (double.IsNaN(estimatedValue) || double.IsInfinity(estimatedValue)) yield return 0.0; … … 50 51 } 51 52 53 private List<double> arguments = new List<double>(); 52 54 public double Evaluate() { 53 55 var currentInstr = code[pc++]; … … 81 83 return p; 82 84 } 85 case CodeSymbol.Call: { 86 // save current arguments 87 var oldArgs = new List<double>(arguments); 88 arguments.Clear(); 89 // evaluate sub-trees 90 for (int i = 0; i < currentInstr.nArguments; i++) { 91 arguments.Add(Evaluate()); 92 } 93 // save the pc 94 int nextPc = pc; 95 // set pc to start of function 96 pc = currentInstr.iArg0; 97 // evaluate the function 98 double v = Evaluate(); 99 // restore the pc => evaluation will continue at point after my subtrees 100 pc = nextPc; 101 // restore arguments 102 arguments = oldArgs; 103 return v; 104 } 105 case CodeSymbol.Arg: { 106 return arguments[currentInstr.iArg0]; 107 } 83 108 case CodeSymbol.Dynamic: { 84 109 var variableTreeNode = currentInstr.dynamicNode as VariableTreeNode;
Note: See TracChangeset
for help on using the changeset viewer.