Ejemplo n.º 1
0
        AsmInstructionDecorator CreateInstruction(AsmInstruction instruction)
        {
            AsmInstructionDecorator decorator = new AsmInstructionDecorator()
            {
                Instruction = instruction,
                Span        = new Span(),
                Name        = CreateInstructionName(instruction),
                Args        = CreateInstructionArgs(instruction),
                Comment     = CreateInstructionComment(instruction)
            };

            int column = m_viewOptions.InstructionPadding;

            decorator.Span.Inlines.Add(decorator.Name);
            column += instruction.Name.Length;

            if (column < m_viewOptions.InstructionArgsPadding)
            {
                Run padding = CreatePadding(m_viewOptions.InstructionArgsPadding - column);
                decorator.Span.Inlines.Add(padding);
                column = m_viewOptions.InstructionArgsPadding;
            }

            if (decorator.Args != null)
            {
                for (int i = 0; i < decorator.Args.Count; ++i)
                {
                    AsmInstructionArgDecorator arg = decorator.Args[i];
                    decorator.Span.Inlines.Add(arg.Run);
                    column += arg.Run.Text.Length;

                    if ((i + 1) != decorator.Args.Count)
                    {
                        decorator.Span.Inlines.Add(new Run(", "));
                        column += 2;
                    }
                }
            }

            if (decorator.Comment != null)
            {
                if (column < m_viewOptions.CommentPadding)
                {
                    Run padding = CreatePadding(m_viewOptions.CommentPadding - column);
                    decorator.Span.Inlines.Add(padding);
                }

                decorator.Span.Inlines.Add(decorator.Comment);
            }

            return(decorator);
        }
Ejemplo n.º 2
0
        List <AsmInstructionArgDecorator> CreateInstructionArgs(AsmInstruction instruction)
        {
            List <AsmInstructionArgDecorator> args = null;

            if (instruction.Args != null)
            {
                args = new List <AsmInstructionArgDecorator>();

                foreach (IAsmInstructionArg arg in instruction.Args)
                {
                    AsmInstructionArgDecorator decoratedArg = new AsmInstructionArgDecorator()
                    {
                        Arg = arg,
                        Run = CreateInstructionArg(arg)
                    };
                    args.Add(decoratedArg);
                }
            }

            return(args);
        }