예제 #1
0
        public Function ConvertFunction(ME3Function obj)
        {
            VariableType returnType = null;

            if (obj.ReturnValue != null)
            {
                returnType = ConvertVariable(obj.ReturnValue).VarType;
            }
            var parameters = new List <FunctionParameter>();

            foreach (var param in obj.Parameters)
            {
                var convert = ConvertVariable(param);
                parameters.Add(new FunctionParameter(convert.VarType,
                                                     convert.Specifiers, convert.Variables.First(),
                                                     null, null));
            }

            var ByteCode = new ME3ByteCodeDecompiler(obj, parameters);
            var body     = ByteCode.Decompile();

            var func = new Function(obj.Name, returnType, body,
                                    new List <Specifier>(), parameters, null, null);

            var locals = new List <VariableDeclaration>();

            foreach (var local in obj.LocalVariables)
            {
                var convert = ConvertVariable(local);
                convert.Outer = func;
                locals.Add(convert);
            }
            func.Locals = locals;
            return(func);
        }
예제 #2
0
        public override bool ResolveLinks()
        {
            var result = base.ResolveLinks();

            var entry = PCC.GetObjectEntry(_FuncIndex);

            if (entry != null)
            {
                FunctionName = entry.ObjectName;
                Function     = PCC.GetObjectEntry(_FuncIndex).Object as ME3Function;
            }
            if (Function == null) // TODO
            {
                return(true);     // this should be false, but until native objects are handled by the library this will have to do.
            }
            entry = PCC.GetObjectEntry(_DeleIndex);
            if (entry != null)
            {
                DelegateName = entry.ObjectName;
                Delegate     = PCC.GetObjectEntry(_DeleIndex).Object as ME3Function;
            }
            if (Delegate == null) // TODO
            {
                return(true);     // this should be false, but until native objects are handled by the library this will have to do.
            }
            return(result);
        }
예제 #3
0
        public override bool ResolveLinks()
        {
            var result = base.ResolveLinks();

            var entry = PCC.GetObjectEntry(_FuncIndex);
            if (entry != null)
            {
                FunctionName = entry.ObjectName;
                Function = PCC.GetObjectEntry(_FuncIndex).Object as ME3Function;
            }
            if (Function == null) // TODO
                return true; // this should be false, but until native objects are handled by the library this will have to do.

            entry = PCC.GetObjectEntry(_DeleIndex);
            if (entry != null)
            {
                DelegateName = entry.ObjectName;
                Delegate = PCC.GetObjectEntry(_DeleIndex).Object as ME3Function;
            }
            if (Delegate == null) // TODO
                return true; // this should be false, but until native objects are handled by the library this will have to do.

            return result;
        }
예제 #4
0
파일: PCCFile.cs 프로젝트: Mgamerz/ME3Libs
        private bool DeserializeExportObject(ExportTableEntry entry)
        {
            switch (entry.ClassName)
            {
            case "Class":
                var classObj = new ME3Class(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = classObj;
                return(classObj.Deserialize());

            case "Function":
                var funcObj = new ME3Function(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = funcObj;
                return(funcObj.Deserialize());

            case "Struct":
                var structObj = new ME3Struct(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = structObj;
                return(structObj.Deserialize());

            case "ScriptStruct":
                var scriptstructObj = new ME3ScriptStruct(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = scriptstructObj;
                return(scriptstructObj.Deserialize());

            case "Enum":
                var enumObj = new ME3Enum(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = enumObj;
                return(enumObj.Deserialize());

            case "Const":
                var constObj = new ME3Const(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = constObj;
                return(constObj.Deserialize());

            case "State":
                var stateObj = new ME3State(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = stateObj;
                return(stateObj.Deserialize());

            case "ArrayProperty":
                var arrayProp = new ME3ArrayProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = arrayProp;
                return(arrayProp.Deserialize());

            case "IntProperty":
                var intProp = new ME3IntProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = intProp;
                return(intProp.Deserialize());

            case "BoolProperty":
                var boolProp = new ME3BoolProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = boolProp;
                return(boolProp.Deserialize());

            case "ByteProperty":
                var byteProp = new ME3ByteProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = byteProp;
                return(byteProp.Deserialize());

            case "ObjectProperty":
                var objectProp = new ME3ObjectProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = objectProp;
                return(objectProp.Deserialize());

            case "ClassProperty":
                var classProp = new ME3ClassProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = classProp;
                return(classProp.Deserialize());

            case "ComponentProperty":
                var compProp = new ME3ComponentProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = compProp;
                return(compProp.Deserialize());

            case "DelegateProperty":
                var deleProp = new ME3DelegateProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = deleProp;
                return(deleProp.Deserialize());

            case "FixedArrayProperty":
                var fixedProp = new ME3FixedArrayProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = fixedProp;
                return(fixedProp.Deserialize());

            case "FloatProperty":
                var floatProp = new ME3FloatProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = floatProp;
                return(floatProp.Deserialize());

            case "InterfaceProperty":
                var interfaceProp = new ME3InterfaceProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = interfaceProp;
                return(interfaceProp.Deserialize());

            case "NameProperty":
                var nameProp = new ME3NameProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = nameProp;
                return(nameProp.Deserialize());

            case "StrProperty":
                var strProp = new ME3StrProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = strProp;
                return(strProp.Deserialize());

            case "StructProperty":
                var structProp = new ME3StructProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = structProp;
                return(structProp.Deserialize());

            default:
                var obj = new ME3Object(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                entry.Object = obj;
                return(obj.Deserialize());
            }
        }
예제 #5
0
        public Function ConvertFunction(ME3Function obj)
        {
            VariableType returnType = null;
            if (obj.ReturnValue != null)
                returnType = ConvertVariable(obj.ReturnValue).VarType;
            var parameters = new List<FunctionParameter>();
            foreach(var param in obj.Parameters)
            {
                var convert = ConvertVariable(param);
                parameters.Add(new FunctionParameter(convert.VarType,
                    convert.Specifiers, convert.Variables.First(),
                    null, null));
            }

            var ByteCode = new ME3ByteCodeDecompiler(obj, parameters);
            var body = ByteCode.Decompile();

            var func = new Function(obj.Name, returnType, body,
                new List<Specifier>(), parameters, null, null);

            var locals = new List<VariableDeclaration>();
            foreach (var local in obj.LocalVariables)
            {
                var convert = ConvertVariable(local);
                convert.Outer = func;
                locals.Add(convert);
            }
            func.Locals = locals;
            return func;
        }
예제 #6
0
파일: PCCFile.cs 프로젝트: Mgamerz/ME3Libs
        private bool DeserializeExportObject(ExportTableEntry entry)
        {
            switch (entry.ClassName)
            {
                case "Class":
                    var classObj = new ME3Class(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = classObj;
                    return classObj.Deserialize();

                case "Function":
                    var funcObj = new ME3Function(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = funcObj;
                    return funcObj.Deserialize();

                case "Struct":
                    var structObj = new ME3Struct(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = structObj;
                    return structObj.Deserialize();

                case "ScriptStruct":
                    var scriptstructObj = new ME3ScriptStruct(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = scriptstructObj;
                    return scriptstructObj.Deserialize();

                case "Enum":
                    var enumObj = new ME3Enum(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = enumObj;
                    return enumObj.Deserialize();

                case "Const":
                    var constObj = new ME3Const(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = constObj;
                    return constObj.Deserialize();

                case "State":
                    var stateObj = new ME3State(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = stateObj;
                    return stateObj.Deserialize();

                case "ArrayProperty":
                    var arrayProp = new ME3ArrayProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = arrayProp;
                    return arrayProp.Deserialize();

                case "IntProperty":
                    var intProp = new ME3IntProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = intProp;
                    return intProp.Deserialize();

                case "BoolProperty":
                    var boolProp = new ME3BoolProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = boolProp;
                    return boolProp.Deserialize();

                case "ByteProperty":
                    var byteProp = new ME3ByteProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = byteProp;
                    return byteProp.Deserialize();

                case "ObjectProperty":
                    var objectProp = new ME3ObjectProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = objectProp;
                    return objectProp.Deserialize();

                case "ClassProperty":
                    var classProp = new ME3ClassProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = classProp;
                    return classProp.Deserialize();

                case "ComponentProperty":
                    var compProp = new ME3ComponentProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = compProp;
                    return compProp.Deserialize();

                case "DelegateProperty":
                    var deleProp = new ME3DelegateProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = deleProp;
                    return deleProp.Deserialize();

                case "FixedArrayProperty":
                    var fixedProp = new ME3FixedArrayProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = fixedProp;
                    return fixedProp.Deserialize();

                case "FloatProperty":
                    var floatProp = new ME3FloatProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = floatProp;
                    return floatProp.Deserialize();

                case "InterfaceProperty":
                    var interfaceProp = new ME3InterfaceProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = interfaceProp;
                    return interfaceProp.Deserialize();

                case "NameProperty":
                    var nameProp = new ME3NameProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = nameProp;
                    return nameProp.Deserialize();

                case "StrProperty":
                    var strProp = new ME3StrProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = strProp;
                    return strProp.Deserialize();

                case "StructProperty":
                    var structProp = new ME3StructProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = structProp;
                    return structProp.Deserialize();

                default :
                    var obj = new ME3Object(Data.GetReader(entry.FileOffset, entry.Size), entry, this);
                    entry.Object = obj;
                    return obj.Deserialize();
            }
        }