示例#1
0
 public LocalsStore(DebuggerService debuggerService, Interpreter interpreter)
 {
     this.debuggerService = debuggerService;
     this.interpreter     = interpreter;
     this.rootVariable    = new LocalVariablesRoot(interpreter);
     this.RootNode.SetValue(ColumnUpdateChilds, true);
 }
示例#2
0
            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)}");
            }
示例#3
0
            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)}");
            }
示例#4
0
 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);
     }
 }
示例#5
0
        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);
            }
        }
示例#6
0
 private bool IsScope(AbstractVariable variable)
 {
     return(variable.GetType() == typeof(Scope));
 }
示例#7
0
 public AbstractVariable SetVariable(AbstractVariable variable)
 {
     _variables.Add(variable);
     return(variable);
 }
示例#8
0
        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);
                }
            }
        }
示例#9
0
        void UpdateNodeRecursive(RemoteTreeNode node, AbstractVariable variable)
        {
            bool abort = false;

            UpdateNodeRecursive(node, variable, ref abort);
        }