Beispiel #1
0
        public void Test_AsmSourceTools_Get_Related_Constant()
        {
            int nBits = 64;

            ulong  value    = 3352562;
            string original = value.ToString(Culture);
            string related  = AsmSourceTools.Get_Related_Constant(original, value, nBits);

            Console.WriteLine(related);
        }
Beispiel #2
0
        /// <summary>
        /// The currently highlighted word has changed. Update the adornments to reflect this change
        /// </summary>
        private void Update_Word_Adornments()
        {
            try
            {
                DateTime time1 = DateTime.Now;

                if (this.NewWord.Length > 0)
                {
                    ITextSnapshot s  = this.RequestedPoint.Snapshot;
                    SnapshotSpan  sp = this.NewWordSpan.Value;

                    // Find the new spans
                    FindData findData;
                    Rn       reg = RegisterTools.ParseRn(this.NewWord);
                    if (reg != Rn.NOREG)
                    {
                        AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Update_Word_Adornments. Register={1}", this.ToString(), this.NewWord));
                        string t = RegisterTools.GetRelatedRegister(reg);
                        findData = new FindData(t, s)
                        {
                            FindOptions = FindOptions.WholeWord | FindOptions.SingleLine | FindOptions.UseRegularExpressions,
                        };
                    }
                    else
                    {
                        (bool valid, ulong value, int nBits) = AsmSourceTools.Parse_Constant(this.NewWord);
                        if (valid)
                        {
                            AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Update_Word_Adornments. Contant={1}", this.ToString(), this.NewWord));
                            string t = AsmSourceTools.Get_Related_Constant(this.NewWord, value, nBits);
                            findData = new FindData(t, s)
                            {
                                FindOptions = FindOptions.WholeWord | FindOptions.SingleLine | FindOptions.UseRegularExpressions,
                            };
                        }
                        else
                        {
                            AsmDudeToolsStatic.Output_INFO(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:Update_Word_Adornments. Keyword={1}", this.ToString(), this.NewWord));
                            //We have to replace all occurrences of special characters with escaped versions of that char since we cannot use verbatim strings.
                            string t = this.NewWord.Replace(".", "\\.").Replace("$", "\\$").Replace("?", "\\?").Replace("/", "\\/");
                            findData = new FindData(t, s)
                            {
                                FindOptions = FindOptions.WholeWord | FindOptions.SingleLine | FindOptions.UseRegularExpressions,
                            };
                        }
                    }

                    List <SnapshotSpan> wordSpans = new List <SnapshotSpan>();
                    try
                    {
                        wordSpans.AddRange(this.textSearchService_.FindAll(findData));
                    }
                    catch (Exception e2)
                    {
                        AsmDudeToolsStatic.Output_WARNING(string.Format(AsmDudeToolsStatic.CultureUI, "could not highlight string \"{0}\"; e={1}", findData.SearchString, e2.InnerException.Message));
                    }
                    this.SynchronousUpdate(this.RequestedPoint, new NormalizedSnapshotSpanCollection(wordSpans), this.NewWord, sp);
                }
                else
                {
                    // If we couldn't find a word, just clear out the existing markers
                    this.SynchronousUpdate(this.RequestedPoint, new NormalizedSnapshotSpanCollection(), null, null);
                }
                AsmDudeToolsStatic.Print_Speed_Warning(time1, "HighlightWordTagger");
            }
            catch (Exception e)
            {
                AsmDudeToolsStatic.Output_ERROR(string.Format(AsmDudeToolsStatic.CultureUI, "{0}:UpdateWordAdornments; e={1}", this.ToString(), e.ToString()));
            }
        }