Exemple #1
0
        public static bool SetLabel(UInt32 address, AddressType type, string label, string comment, bool raiseEvent = true, CodeLabelFlags flags = CodeLabelFlags.None)
        {
            if (_reverseLookup.ContainsKey(label))
            {
                //Another identical label exists, we need to remove it
                CodeLabel existingLabel = _reverseLookup[label];
                DeleteLabel(existingLabel.Address, existingLabel.AddressType, false);
            }

            UInt32 key = GetKey(address, type);

            if (_labels.ContainsKey(key))
            {
                _reverseLookup.Remove(_labels[key].Label);
            }

            _labels[key] = new CodeLabel()
            {
                Address = address, AddressType = type, Label = label, Comment = comment, Flags = flags
            };
            if (label.Length > 0)
            {
                _reverseLookup[label] = _labels[key];
            }

            InteropEmu.DebugSetLabel(address, type, label, comment.Replace(Environment.NewLine, "\n"));
            if (raiseEvent)
            {
                OnLabelUpdated?.Invoke(null, null);
            }

            return(true);
        }
        public static bool SetLabel(UInt32 address, AddressType type, string label, string comment, bool raiseEvent = true, CodeLabelFlags flags = CodeLabelFlags.None, UInt32 labelLength = 1)
        {
            if (_reverseLookup.ContainsKey(label))
            {
                //Another identical label exists, we need to remove it
                CodeLabel existingLabel = _reverseLookup[label];
                DeleteLabel(existingLabel, false);
            }

            CodeLabel newLabel = new CodeLabel()
            {
                Address = address, AddressType = type, Label = label, Comment = comment, Flags = flags, Length = labelLength
            };

            for (UInt32 i = address; i < address + labelLength; i++)
            {
                UInt32    key = GetKey(i, type);
                CodeLabel existingLabel;
                if (_labelsByKey.TryGetValue(key, out existingLabel))
                {
                    _reverseLookup.Remove(existingLabel.Label);
                }

                _labelsByKey[key] = newLabel;

                if (labelLength == 1)
                {
                    InteropEmu.DebugSetLabel(i, type, label, comment.Replace(Environment.NewLine, "\n"));
                }
                else
                {
                    InteropEmu.DebugSetLabel(i, type, label + "+" + (i - address).ToString(), comment.Replace(Environment.NewLine, "\n"));

                    //Only set the comment on the first byte of multi-byte comments
                    comment = "";
                }
            }

            _labels.Add(newLabel);
            if (label.Length > 0)
            {
                _reverseLookup[label] = newLabel;
            }

            if (raiseEvent)
            {
                OnLabelUpdated?.Invoke(null, null);
            }

            return(true);
        }