public LocalsStore(DebuggerService debuggerService, Interpreter interpreter) { this.debuggerService = debuggerService; this.interpreter = interpreter; this.rootVariable = new LocalVariablesRoot(interpreter); this.RootNode.SetValue(ColumnUpdateChilds, true); }
static void WriteEnemyVariables <T>(object textLeft, AbstractVariable <T> variableLeft, AbstractVariable <T> variableRight, CustomColor enemyColor, CustomColor foregroundColor = ColorUtils.ForegroundDefault, CustomColor backgroundColor = ColorUtils.BackgroundDefault) { Console.ForegroundColor = (ConsoleColor)enemyColor; Console.BackgroundColor = (ConsoleColor)backgroundColor; Console.Write($"{textLeft,-Cmd.TextWidthLeft}"); Console.ForegroundColor = (ConsoleColor)(variableLeft.IsChanged ? enemyColor : foregroundColor); Console.Write($"{variableLeft,Cmd.TextWidthRight - 15}"); Console.ForegroundColor = (ConsoleColor)(variableRight.IsChanged ? enemyColor : foregroundColor); Console.Write($"{variableRight,Cmd.TextWidthRight - 10}"); Console.BackgroundColor = (ConsoleColor)backgroundColor; Console.WriteLine($"{new string(' ', Cmd.TextWidthFull)}"); }
static void WriteVariable <T>(object textLeft, AbstractVariable <T> variable, CustomColor foregroundColorModify, CustomColor foregroundColor = ColorUtils.ForegroundDefault, CustomColor backgroundColor = ColorUtils.BackgroundDefault) { Console.ForegroundColor = (ConsoleColor)foregroundColor; Console.BackgroundColor = (ConsoleColor)backgroundColor; Console.Write($"{textLeft,-Cmd.TextWidthLeft}"); if (variable.IsChanged) { Console.ForegroundColor = (ConsoleColor)foregroundColorModify; } Console.Write($"{variable,Cmd.TextWidthRight}"); Console.BackgroundColor = (ConsoleColor)backgroundColor; Console.WriteLine($"{new string(' ', Cmd.TextWidthFull)}"); }
private void Multiplier() { if (IsType(TokenType.varName)) { AbstractVariable aVar = _table.GetVariable(_scanner.GetToken().Value); _gen.Addr(aVar); _gen.Cmd(VMCommands.cmLoad); _scanner.NextToken(); } else if (IsType(TokenType.number)) { _gen.Const(_scanner.GetToken().Value); Number(); } else { Check(TokenType.leftBracket, 170); SimpleExpression(); Check(TokenType.rightBracket, 172); } }
private void Variable() { string varName = _scanner.GetToken().Value; _scanner.NextToken(); if (IsType(TokenType.colon)) { _table.CheckIfVarExist(varName); _scanner.NextToken(); Check(TokenType.intType, 111); _table.SetVariable(new NumberVariable(varName)); } if (IsType(TokenType.equel)) { _scanner.NextToken(); AbstractVariable variable = _table.GetVariable(varName); _gen.Addr(variable); SimpleExpression(); _gen.Cmd(VMCommands.cmSave); Check(TokenType.semicolon, 121); } }
private bool IsScope(AbstractVariable variable) { return(variable.GetType() == typeof(Scope)); }
public AbstractVariable SetVariable(AbstractVariable variable) { _variables.Add(variable); return(variable); }
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); }