Пример #1
0
        void SetupAsm()
        {
            m_text.Text         = "";
            m_decoratedFunction = null;

            AsmFunction function = SearchFunction(m_window.ActiveAsm.Functions, m_window.CurrentLine);

            if (function != null)
            {
                SetupFunction(function);
            }
        }
Пример #2
0
        void AddFunctionHeader(AsmFunction function)
        {
            m_decoratedFunction = new AsmFunctionDecorator()
            {
                Function = function,
                Run      = new Run(function.Name)
                {
                    Foreground = FunctionForeground
                },
                Blocks = new List <AsmBlockDecorator>()
            };

            m_text.Inlines.Add(m_decoratedFunction.Run);
            m_text.Inlines.Add(new Run(Environment.NewLine));
        }
Пример #3
0
        void SetupFunction(AsmFunction function)
        {
            if (m_viewOptions == null)
            {
                m_viewOptions = (ViewOptions)VSAsmPackage.Instance.GetDialogPage(typeof(ViewOptions));
            }

            AddFunctionHeader(function);

            int index = 0;

            foreach (AsmBlock block in function.Blocks)
            {
                AddBlock(index, block);
                ++index;
            }
        }
Пример #4
0
        static AsmFunction SearchFunction(List <AsmFunction> functions, int line)
        {
            int first = 0;
            int count = functions.Count;

            while (0 < count)
            {
                int         middle         = count / 2;
                AsmFunction middleFunction = functions[first + middle];
                if (middleFunction.Range.Min < line)
                {
                    first  = middle + 1;
                    count -= middle + 1;
                }
                else
                {
                    count = middle;
                }
            }

            if (first == functions.Count)
            {
                return(null);
            }

            AsmFunction function = functions[first];

            if (function.Range.Contains(line))
            {
                return(function);
            }

            if (first != 0)
            {
                function = functions[first - 1];
                if (function.Range.Contains(line))
                {
                    return(function);
                }
            }

            return(null);
        }
Пример #5
0
        AsmFunction ParseFunction()
        {
            AsmFunction function = ParseFunctionSignature(CurrentLine);

            NextLine();
            List <AsmBlock> blocks = new List <AsmBlock>();

            while (!CurrentLine.Contains(FunctionEndID))
            {
                blocks.Add(ParseBlock());
            }

            function.Blocks = blocks.ToArray();
            Array.Sort(function.Blocks);

            function.Range = new LineRange(function.Blocks[0].Range.Min,
                                           function.Blocks[function.Blocks.Length - 1].Range.Max);
            return(function);
        }