Example #1
0
        private void FormatInternal(IlProgram program, CodeFormatSettings formatSettings)
        {
            for (var idx = 0; idx < program.IlMethods.Count; idx++)
            {
                if (idx != 0)
                {
                    _builder.AppendLine();
                }

                var method     = (IlMethod)program.IlMethods[idx];
                var methodName = program.MethodNames[method.Address];

                _builder.Append(SyntaxFacts.GetAttributeText(SyntaxKind.Attribute_Method));
                _builder.Append(' ');
                _builder.Append(methodName);
                _builder.AppendLine(":");

                if (method.Address == program.EntryPoint)
                {
                    _builder.Append(' ', formatSettings.LineIndentSize);
                    _builder.AppendLine(SyntaxFacts.GetAttributeText(SyntaxKind.Attribute_Entrypoint));
                }

                if (method.Args != 0)
                {
                    _builder.Append(' ', formatSettings.LineIndentSize);
                    _builder.Append(SyntaxFacts.GetAttributeText(SyntaxKind.Attribute_Args));
                    _builder.Append(' ');
                    _builder.AppendLine(method.Args.ToString());
                }

                var locals = GetLocalsSize(method.IlObjects);

                if (locals != 0)
                {
                    _builder.Append(' ', formatSettings.LineIndentSize);
                    _builder.Append(SyntaxFacts.GetAttributeText(SyntaxKind.Attribute_Locals));
                    _builder.Append(' ');
                    _builder.AppendLine(locals.ToString());
                }

                FormatMethod(method, program, formatSettings);
            }