Exemplo n.º 1
0
        public string GetMethodSourceCode(ICodeResult result, PapyrusMethodDefinition method)
        {
            var sb = new StringBuilder();

            var methodBody = result.DecompiledSourceCode;
            var isNone     = method.ReturnTypeName.Value.ToLower() == "none";
            var name       = method.Name?.Value;

            if (string.IsNullOrEmpty(name))
            {
                if (method.IsSetter)
                {
                    name = "Set";
                }
                if (method.IsSetter)
                {
                    name = "Get";
                }
            }
            var returnValue = "";
            var fDesc       = "Function";

            if (method.IsEvent)
            {
                fDesc = "Event";
            }
            else if (!isNone)
            {
                returnValue = method.ReturnTypeName.Value + " ";
            }

            var last = "";

            if (method.IsNative)
            {
                last += " Native";
            }
            if (method.IsGlobal)
            {
                last += " Global";
            }

            var parameters = GetParameterString(method.Parameters);

            sb.AppendLine(returnValue + fDesc + " " + name + parameters + last);

            if (!string.IsNullOrEmpty(method.Documentation?.Value))
            {
                sb.AppendLine("{ " + method.Documentation?.Value + " }");
            }

            sb.AppendLine(IndentedLines(1, methodBody.Trim('\n', '\r')));

            if (!method.IsNative)
            {
                sb.AppendLine("End" + fDesc);
            }

            return(sb.ToString().Trim('\n'));
        }
Exemplo n.º 2
0
 public Return(GeneratorScope scope, ICodeResult result) : base(scope, null, null)
 {
     Construct = result;
 }