public LocalsStore(DebuggerService debuggerService, Interpreter interpreter) { this.debuggerService = debuggerService; this.interpreter = interpreter; this.rootVariable = new LocalVariablesRoot(interpreter); this.RootNode.SetValue(ColumnUpdateChilds, true); }
AbstractVariable[] GetChildNodes() { long childCount = (long)endIndex - (long)startIndex + 1; if (childCount <= SubsetMaximalSize) { // Return array of all childs AbstractVariable[] childs = new AbstractVariable[childCount]; for (int i = 0; i < childCount; i++) { childs[i] = GetChildNode(startIndex + i); } return(childs); } else { // Subdivide to smaller groups long groupSize = SubsetOptimalSize; // The number of groups must not be too big either // Increase groupSize if necessary long groupCount; while (true) { groupCount = ((childCount - 1) / groupSize) + 1; // Round up if (groupCount <= SubsetMaximalSize) { break; } else { groupSize *= SubsetOptimalSize; } } // Return the smaller groups AbstractVariable[] childs = new AbstractVariable[groupCount]; for (int i = 0; i < groupCount; i++) { long start = startIndex + i * groupSize; long end = System.Math.Min(upperBound, start + groupSize - 1); childs[i] = new ArraySubsetVariable(stackFrame, obj, indicesPefix, (int)start, (int)end); } return(childs); } }
void UpdateNodeRecursive(RemoteTreeNode node, AbstractVariable variable, ref bool abort) { // Get full name of the node string fullNamePrefix; if (node != RootNode && node.Parent != RootNode) { fullNamePrefix = (string)node.Parent.GetValue(ColumnFullName) + "."; } else { fullNamePrefix = String.Empty; } string fullName = fullNamePrefix + variable.Name; // Update the node itself node.Tag = variable; node.SetValue(ColumnFullName, fullName); node.SetValue(ColumnImage, variable.Image); node.SetValue(ColumnName, variable.Name); node.SetValue(ColumnValue, variable.Value); node.SetValue(ColumnType, variable.Type); // Recursively update the childs of this node bool updateChilds = node.GetValue(ColumnUpdateChilds) != null && (bool)node.GetValue(ColumnUpdateChilds); if (!variable.HasChildNodes) { // Does not have childs node.Clear(); } else if (!updateChilds) { // Has childs but do not update them if (node.ChildCount == 0) { // Placeholder so that the item is expandable node.AppendNode(); } } else { // Update childs AbstractVariable[] variables; try { variables = ((AbstractVariable)node.Tag).ChildNodes; } catch { variables = new AbstractVariable[] { new ErrorVariable(String.Empty, "Can not get child nodes") }; } Console.WriteLine("{0} current nodes, {1} new variables", node.ChildCount, variables.Length); // Iterate over the current tree nodes and update them // Try to do it with minimal number of changes to the tree for(int i = 0; i < node.ChildCount; /* no-op */ ) { if (abort) return; string childNodeName = (string)node.GetChild(i).GetValue(ColumnName); // Update 'i'th node to 'i'th variable // Find a variable with the same name as this node // (includes the case where there are no variables left) int varIndex = -1; for(int j = i; j < variables.Length; j++) { if (variables[j].Name == childNodeName) { varIndex = j; break; } } Console.WriteLine("Looking for variable '{0}': index = {1}", childNodeName, varIndex); // Not found - remove this node if (varIndex == -1) { node.GetChild(i).Remove(); continue; } // Insert the variables before the match while(i < varIndex) { UpdateNodeRecursive(node.InsertNode(i), variables[i], ref abort); i++; } // Update the match UpdateNodeRecursive(node.GetChild(i), variables[i], ref abort); i++; } // Add any variables left over for(int i = node.ChildCount; i < variables.Length; i++) { RemoteTreeNode newNode = node.AppendNode(); UpdateNodeRecursive(newNode, variables[i], ref abort); } } }
void UpdateNodeRecursive(RemoteTreeNode node, AbstractVariable variable) { bool abort = false; UpdateNodeRecursive(node, variable, ref abort); }
AbstractVariable[] GetChildNodes() { long childCount = (long)endIndex - (long)startIndex + 1; if (childCount <= SubsetMaximalSize) { // Return array of all childs AbstractVariable[] childs = new AbstractVariable[childCount]; for(int i = 0; i < childCount; i++) { childs[i] = GetChildNode(startIndex + i); } return childs; } else { // Subdivide to smaller groups long groupSize = SubsetOptimalSize; // The number of groups must not be too big either // Increase groupSize if necessary long groupCount; while(true) { groupCount = ((childCount - 1) / groupSize) + 1; // Round up if (groupCount <= SubsetMaximalSize) { break; } else { groupSize *= SubsetOptimalSize; } } // Return the smaller groups AbstractVariable[] childs = new AbstractVariable[groupCount]; for(int i = 0; i < groupCount; i++) { long start = startIndex + i * groupSize; long end = System.Math.Min(upperBound, start + groupSize - 1); childs[i] = new ArraySubsetVariable(stackFrame, obj, indicesPefix, (int)start, (int)end); } return childs; } }