Ejemplo n.º 1
0
		public VariableUpdateEventArgs(VariableUpdateType type, LuaValue thread, VariableDetails[] vars, bool cacheFlush)
		{
			mType = type;
			mThread = thread;
			mVariables = vars;
			mCacheFlush = cacheFlush;
		}
Ejemplo n.º 2
0
        protected TreeTableNode FindClosestAncestor(VariableDetails var)
        {
            // Check if its in there exactly
            string searchkey = var.ToString();

            if (variablesListView.ContainsKey(searchkey))
            {
                return(variablesListView[searchkey]);
            }

            // 3>2:STRING.123323253:NUMBER.5:USERDATA

            // Find its closest ancestor
            int separator;

            while ((separator = searchkey.LastIndexOf('.')) >= 0)
            {
                searchkey = searchkey.Substring(0, separator);
                if (variablesListView.ContainsKey(searchkey))
                {
                    return(variablesListView[searchkey]);
                }
            }
            return(variablesListView.Root);
        }
Ejemplo n.º 3
0
            public int Compare(TreeTableNode x, TreeTableNode y)
            {
                VariableDetails varx = (VariableDetails)x.Tag;
                VariableDetails vary = (VariableDetails)y.Tag;

                int orderx, ordery;

                m_typeOrder.TryGetValue(varx.Key.Type, out orderx);
                m_typeOrder.TryGetValue(vary.Key.Type, out ordery);

                if (varx.Key.Type == LuaValueType.NUMBER && vary.Key.Type == LuaValueType.NUMBER)
                {
                    return(Math.Sign(varx.Key.AsNumber() - vary.Key.AsNumber()));
                }
                else if (orderx == ordery)
                {
                    string keyx = mDebugger.GetValueString(varx.Key);
                    string keyy = mDebugger.GetValueString(vary.Key);
                    return(String.Compare(keyx, keyy));
                }
                else
                {
                    return(ordery - orderx);
                }
            }
Ejemplo n.º 4
0
        void ReadVariables(List <VariableDetails> vars, List <LuaValue> path, int watchid, int count, int depth)
        {
            for (int index = 0; index < count; ++index)
            {
                LuaValue         key         = m_readBuffer.ReadValue();
                LuaValue         value       = m_readBuffer.ReadValue();
                VariableInfoFlag flags       = (VariableInfoFlag)m_readBuffer.ReadInt16();
                bool             valid       = (flags & VariableInfoFlag.Valid) != 0;
                bool             expanded    = (flags & VariableInfoFlag.Expanded) != 0;
                bool             hasEntries  = (flags & VariableInfoFlag.HasEntries) != 0;
                bool             hasMetadata = (flags & VariableInfoFlag.HasMetadata) != 0;
                VariableClass    varclass    = (VariableClass)m_readBuffer.ReadInt16();

                VariableDetails var = new VariableDetails(watchid, path.ToArray(), key, value, expanded, hasEntries, hasMetadata, valid, varclass);
                vars.Add(var);

                int expansionCount = m_readBuffer.ReadInt32();
                if (expansionCount > 0)
                {
                    path.Add(key);
                    ReadVariables(vars, path, watchid, expansionCount, depth + 1);
                    path.RemoveAt(path.Count - 1);
                }
            }
        }
Ejemplo n.º 5
0
        void variablesListView_NodeOpened(TreeTableNode node)
        {
            VariableDetails details = (VariableDetails)node.Tag;

            mDebugger.Manager.StartProgressBarMarquee();

            mDebugger.ConnectedTarget.ExpandLocal(details.MakePath());
            mDebugger.ConnectedTarget.RetrieveLocals(mDebugger.CurrentThread, mDebugger.CurrentStackFrame.Depth);
        }
Ejemplo n.º 6
0
        private void DeleteWatch(TreeTableNode node)
        {
            VariableDetails varInfo = (VariableDetails)node.Tag;
            WatchDetails    watch   = mDebugger.FindWatch(varInfo.WatchID);

            if (watch != null)
            {
                mDebugger.RemoveWatch(watch);
            }
            node.Parent.Items.Remove(node);
        }
Ejemplo n.º 7
0
        private void UpdateFilterRecursive(TreeTableNode root)
        {
            foreach (TreeTableNode child in root.Items)
            {
                VariableDetails details = (VariableDetails)child.Tag;

                child.Visible    = IsVariableVisible(details);
                child.Expandable = details.HasEntries || (details.HasMetadata && ShowMetadata);

                UpdateFilterRecursive(child);
            }
        }
Ejemplo n.º 8
0
        void variablesListView_NodeClosed(TreeTableNode node)
        {
            VariableDetails details = (VariableDetails)node.Tag;

            if (!mUpdateInProgress && mDebugger.ConnectedTarget != null && mDebugger.CurrentStackFrame != null)
            {
                mDebugger.Manager.StartProgressBarMarquee();

                mDebugger.ConnectedTarget.CloseWatch(details.WatchID, details.MakePath());
                mDebugger.ConnectedTarget.UpdateWatch(details.WatchID, mDebugger.CurrentThread, mDebugger.CurrentStackFrame.Depth);
            }
        }
Ejemplo n.º 9
0
        private bool IsVariableVisible(VariableDetails details)
        {
            bool isMetadata = details.Key.Type == LuaValueType.TILDE_ENVIRONMENT || details.Key.Type == LuaValueType.TILDE_METATABLE || details.Key.Type == LuaValueType.TILDE_UPVALUES;
            bool isFunction = details.Value.Type == LuaValueType.FUNCTION;

            if (details.Path.Length == 0)
            {
                return(true);
            }
            else if ((isMetadata && !mShowMetadata) || (isFunction && !mShowFunctions))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 10
0
        protected TreeTableNode AddVariable(VariableDetails varInfo)
        {
            string value = "";
            string type  = "";

            if (varInfo.Value != null)
            {
                value = QuoteValueString(varInfo.Value);
                type  = varInfo.Value.Type.ToString();
            }

            TreeTableNode node = new TreeTableNode(mDebugger.GetValueString(varInfo.Key));

            node.Key = varInfo.ToString();
            node.Tag = varInfo;
            node.SubItems.Add(value);
            node.SubItems.Add(type);

            if (varInfo.VariableClass == VariableClass.Upvalue)
            {
                node.Font = mBoldFont;
            }

            if (varInfo.Key != null)
            {
                if (varInfo.Key.Type == LuaValueType.TILDE_ENVIRONMENT || varInfo.Key.Type == LuaValueType.TILDE_METATABLE || varInfo.Key.Type == LuaValueType.TILDE_UPVALUES)
                {
                    node.Font = mItalicFont;
                }
            }

            if (varInfo.Value != null)
            {
                node.Expandable = varInfo.HasEntries || (varInfo.HasMetadata && ShowMetadata);
                node.Expanded   = varInfo.Expanded;
            }

            return(node);
        }
Ejemplo n.º 11
0
        protected void UpdateVariable(VariableDetails varInfo)
        {
            if (variablesListView.ContainsKey(varInfo.ToString()))
            {
                TreeTableNode node = variablesListView[varInfo.ToString()];
                node.Tag = varInfo;

                if (!varInfo.Valid)
                {
                    node.Items.Clear();

                    // Only remove the variable if it's not a root watch expression
                    if (varInfo.WatchID > 0 && varInfo.Path.Length == 0)
                    {
                        node.ForeColor        = SystemColors.InactiveCaptionText;
                        node.SubItems[1].Text = QuoteValueString(varInfo.Value);
                        node.SubItems[2].Text = varInfo.Value.Type.ToString();
                    }
                    else
                    {
                        node.Parent.Items.Remove(node);
                    }
                }
                else
                {
                    node.Expandable = varInfo.HasEntries || (varInfo.HasMetadata && ShowMetadata);
                    node.Expanded   = varInfo.Expanded;

                    string value = QuoteValueString(varInfo.Value);

                    if (!varInfo.Expanded)
                    {
                        node.Items.Clear();
                    }

                    if (varInfo.Value.Type == LuaValueType.NONE)
                    {
                        node.Items.Clear();

                        node.ForeColor = SystemColors.InactiveCaptionText;
                    }
                    else if (node.SubItems[1].Text != value || node.SubItems[2].Text != varInfo.Value.Type.ToString())
                    {
                        node.ForeColor        = Color.Red;
                        node.SubItems[1].Text = value;
                        node.SubItems[2].Text = varInfo.Value.Type.ToString();
                    }
                    else
                    {
                        node.ForeColor = variablesListView.ForeColor;
                    }
                }
                node.Visible = IsVariableVisible(varInfo);
            }
            else if (varInfo.Valid && (varInfo.WatchID == 0 || mDebugger.FindWatch(varInfo.WatchID) != null))
            {
                TreeTableNode parent = FindClosestAncestor(varInfo);
                TreeTableNode node   = AddVariable(varInfo);
                parent.Items.Insert(node, mNodeComparer);
                node.Visible = IsVariableVisible(varInfo);
            }
        }
Ejemplo n.º 12
0
		void ReadVariables(List<VariableDetails> vars, List<LuaValue> path, int watchid, int count, int depth)
		{
			for (int index = 0; index < count; ++index)
			{
				LuaValue key = m_readBuffer.ReadValue();
				LuaValue value = m_readBuffer.ReadValue();
				VariableInfoFlag flags = (VariableInfoFlag)m_readBuffer.ReadInt16();
				bool valid = (flags & VariableInfoFlag.Valid) != 0;
				bool expanded = (flags & VariableInfoFlag.Expanded) != 0;
				bool hasEntries = (flags & VariableInfoFlag.HasEntries) != 0;
				bool hasMetadata = (flags & VariableInfoFlag.HasMetadata) != 0;
				VariableClass varclass = (VariableClass)m_readBuffer.ReadInt16();

				VariableDetails var = new VariableDetails(watchid, path.ToArray(), key, value, expanded, hasEntries, hasMetadata, valid, varclass);
				vars.Add(var);

				int expansionCount = m_readBuffer.ReadInt32();
				if (expansionCount > 0)
				{
					path.Add(key);
					ReadVariables(vars, path, watchid, expansionCount, depth + 1);
					path.RemoveAt(path.Count - 1);
				}
			}
		}
Ejemplo n.º 13
0
		private void variablesListView_AfterLabelEdit(object sender, LabelEditEventArgs e)
		{
			m_editInProgress = false;
			contextMenuStrip.Enabled = true;
			toolStrip1.Enabled = true;

			TreeTableNode node = variablesListView.Nodes[e.Item];

			string expression = e.Label == null ? "" : e.Label.Trim();

			variablesListView.BeginUpdate();

			// Did the user cancel adding a new watch?
			if (node.Text == "" && expression == "")
			{
				e.CancelEdit = true;
				node.Parent.Items.Remove(node);
			}

			// Did the user cancel the change?
			else if (e.Label == null || expression == node.Text)
			{
				// Do nothing
			}

			// Did the user delete an existing watch?
			else if(expression == "")
			{
				e.CancelEdit = true;
				DeleteWatch(node);
			}

			// The user modified an existing watch
			else
			{
				VariableDetails oldVar = node.Tag as VariableDetails;
				if (oldVar != null)
				{
					WatchDetails oldWatch = mDebugger.FindWatch(oldVar.WatchID);
					if (oldWatch != null)
						mDebugger.RemoveWatch(oldWatch);
				}

				WatchDetails newWatch = mDebugger.AddWatch(expression);
				VariableDetails newVar = new VariableDetails(newWatch.ID, new LuaValue[] { }, null, null, false, false, false, false, VariableClass.Watch);
				node.Tag = newVar;
				node.Key = newVar.ToString();
				node.Text = expression;
				node.SubItems[1].Text = "";
				node.SubItems[2].Text = "";

				if (mDebugger.ConnectedTarget != null && mDebugger.CurrentStackFrame != null)
					mDebugger.ConnectedTarget.RetrieveWatches(mDebugger.CurrentThread, mDebugger.CurrentStackFrame.Depth);
			}

			variablesListView.EndUpdate();
		}
Ejemplo n.º 14
0
        private void variablesListView_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            m_editInProgress         = false;
            contextMenuStrip.Enabled = true;
            toolStrip1.Enabled       = true;

            TreeTableNode node = variablesListView.Nodes[e.Item];

            string expression = e.Label == null ? "" : e.Label.Trim();

            variablesListView.BeginUpdate();

            // Did the user cancel adding a new watch?
            if (node.Text == "" && expression == "")
            {
                e.CancelEdit = true;
                node.Parent.Items.Remove(node);
            }

            // Did the user cancel the change?
            else if (e.Label == null || expression == node.Text)
            {
                // Do nothing
            }

            // Did the user delete an existing watch?
            else if (expression == "")
            {
                e.CancelEdit = true;
                DeleteWatch(node);
            }

            // The user modified an existing watch
            else
            {
                VariableDetails oldVar = node.Tag as VariableDetails;
                if (oldVar != null)
                {
                    WatchDetails oldWatch = mDebugger.FindWatch(oldVar.WatchID);
                    if (oldWatch != null)
                    {
                        mDebugger.RemoveWatch(oldWatch);
                    }
                }

                WatchDetails    newWatch = mDebugger.AddWatch(expression);
                VariableDetails newVar   = new VariableDetails(newWatch.ID, new LuaValue[] { }, null, null, false, false, false, false, VariableClass.Watch);
                node.Tag              = newVar;
                node.Key              = newVar.ToString();
                node.Text             = expression;
                node.SubItems[1].Text = "";
                node.SubItems[2].Text = "";

                if (mDebugger.ConnectedTarget != null && mDebugger.CurrentStackFrame != null)
                {
                    mDebugger.ConnectedTarget.RetrieveWatches(mDebugger.CurrentThread, mDebugger.CurrentStackFrame.Depth);
                }
            }

            variablesListView.EndUpdate();
        }