Пример #1
0
        public string GetSignature()
        {
            string result = "";

            if (export.ClassName == "Function")
            {
                if (Native)
                {
                    result += "native";
                    if (GetNatIdx() > 0)
                    {
                        result += $"({GetNatIdx()})";
                    }
                    result += " ";
                }

                flags.Except("Native", "Event", "Delegate", "Defined", "Public", "HasDefaults", "HasOutParms").Each(f => result += f.ToLower() + " ");
            }

            if (HasFlag("Event"))
            {
                result += "event ";
            }
            else if (HasFlag("Delegate"))
            {
                result += "delegate ";
            }
            else
            {
                result += export.ClassName.ToLower() + " ";
            }
            string type = GetReturnType();

            if (type != null)
            {
                result += type + " ";
            }
            result += export.ObjectName.Instanced + "(";
            int paramCount = 0;
            var locals     = new List <ExportEntry>();

            //Tokens = new List<BytecodeSingularToken>();
            //Statements = ReadBytecode();

            // OLD CODE
            //List<ExportEntry> childrenReversed = export.FileRef.Exports.Where(x => x.idxLink == export.UIndex).ToList();
            //childrenReversed.Reverse();

            // NEW CODE
            List <ExportEntry> childrenReversed = new List <ExportEntry>();
            var childIdx = EndianReader.ToInt32(export.Data, 0x14, export.FileRef.Endian);

            while (export.FileRef.TryGetUExport(childIdx, out var parsingExp))
            {
                childrenReversed.Add(parsingExp);
                childIdx = EndianReader.ToInt32(parsingExp.Data, 0x10, export.FileRef.Endian);
            }

            //Get local children of this function
            foreach (ExportEntry export in childrenReversed)
            {
                //Reading parameters info...
                if (export.ClassName.EndsWith("Property"))
                {
                    UnrealFlags.EPropertyFlags ObjectFlagsMask = (UnrealFlags.EPropertyFlags)EndianReader.ToUInt64(export.Data, 0x18, export.FileRef.Endian);
                    if (ObjectFlagsMask.HasFlag(UnrealFlags.EPropertyFlags.Parm) && !ObjectFlagsMask.HasFlag(UnrealFlags.EPropertyFlags.ReturnParm))
                    {
                        if (paramCount > 0)
                        {
                            result += ", ";
                        }

                        if (export.ClassName == "ObjectProperty" || export.ClassName == "StructProperty")
                        {
                            var    uindexOfOuter = EndianReader.ToInt32(export.Data, export.Data.Length - 4, export.FileRef.Endian);
                            IEntry entry         = export.FileRef.GetEntry(uindexOfOuter);
                            if (entry != null)
                            {
                                result += entry.ObjectName.Instanced + " ";
                            }
                        }
                        else
                        {
                            result += UnFunction.GetPropertyType(export) + " ";
                        }

                        result += export.ObjectName.Instanced;
                        paramCount++;

                        //if (ObjectFlagsMask.HasFlag(UnrealFlags.EPropertyFlags.OptionalParm) && Statements.Count > 0)
                        //{
                        //    if (Statements[0].Token is NothingToken)
                        //        Statements.RemoveRange(0, 1);
                        //    else if (Statements[0].Token is DefaultParamValueToken)
                        //    {
                        //        result += " = ").Append(Statements[0].Token.ToString());
                        //        Statements.RemoveRange(0, 1);
                        //    }
                        //}
                    }
                    if (ObjectFlagsMask.HasFlag(UnrealFlags.EPropertyFlags.ReturnParm))
                    {
                        break; //return param
                    }
                }
            }
            result += ")";
            return(result);
        }