Changeset 4897 for branches/GP-MemoryOperations/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs
- Timestamp:
- 11/22/10 10:34:37 (14 years ago)
- Location:
- branches/GP-MemoryOperations/HeuristicLab.Problems.DataAnalysis
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-MemoryOperations/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs
r4722 r4897 57 57 public const byte NOT = 15; 58 58 59 60 59 public const byte Average = 16; 61 60 … … 66 65 public const byte Constant = 20; 67 66 public const byte Arg = 21; 67 68 public const byte Set = 22; 69 public const byte Read = 23; 68 70 } 69 71 … … 90 92 { typeof(Constant), OpCodes.Constant }, 91 93 { typeof(Argument), OpCodes.Arg }, 94 { typeof(SetMem), OpCodes.Set }, 95 { typeof(ReadMem), OpCodes.Read }, 92 96 }; 93 97 private const int ARGUMENT_STACK_SIZE = 1024; 98 private const int MAX_MEMORY_SIZE = 128; 94 99 95 100 private Dataset dataset; … … 99 104 private double[] argumentStack = new double[ARGUMENT_STACK_SIZE]; 100 105 private int argStackPointer; 106 private double[] memory = new double[MAX_MEMORY_SIZE]; 101 107 102 108 public override bool CanChangeName { … … 124 130 compiler.AddInstructionPostProcessingHook(PostProcessInstruction); 125 131 code = compiler.Compile(tree, MapSymbolToOpCode); 132 Array.Clear(memory, 0, MAX_MEMORY_SIZE); 126 133 foreach (var row in rows) { 127 134 this.row = row; … … 139 146 var variableTreeNode = instr.dynamicNode as LaggedVariableTreeNode; 140 147 instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName); 148 } else if (instr.opCode == OpCodes.Set) { 149 var setMemTreeNode = instr.dynamicNode as SetMemTreeNode; 150 instr.iArg0 = (ushort)setMemTreeNode.Address; 151 } else if (instr.opCode == OpCodes.Read) { 152 var readMemTreeNode = instr.dynamicNode as ReadMemTreeNode; 153 instr.iArg0 = (ushort)readMemTreeNode.Address; 141 154 } 142 155 return instr; … … 290 303 return constTreeNode.Value; 291 304 } 305 case OpCodes.Set: { 306 double d = Evaluate(); 307 memory[currentInstr.iArg0] = d; 308 return d; 309 } 310 case OpCodes.Read: { 311 return memory[currentInstr.iArg0]; 312 } 292 313 default: throw new NotSupportedException(); 293 314 }
Note: See TracChangeset
for help on using the changeset viewer.